Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a spec and fix rspec matcher [wip]
- Loading branch information
Kris Leech
committed
Jul 4, 2014
1 parent
cfdc665
commit 78af2e2
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'spec_helper' | ||
require 'wisper/rspec/matchers' | ||
|
||
describe WisperMatchers::ShouldPublish do | ||
let(:publisher) do | ||
Class.new do | ||
include Wisper::Publisher | ||
|
||
def execute | ||
broadcast(:it_happened) | ||
end | ||
end.new | ||
end | ||
|
||
describe '#matches?' do | ||
it 'returns false when event not broadcast' do | ||
matcher = WisperMatchers::ShouldPublish.new(publisher, :it_happened) | ||
result = matcher.matches? { publisher } | ||
expect(result).to be_falsey | ||
end | ||
|
||
it 'returns true when event broadcast' do | ||
matcher = WisperMatchers::ShouldPublish.new(publisher, :it_happened) | ||
result = matcher.matches? { publisher.execute } | ||
|
||
expect(result).to be_truthy | ||
end | ||
end | ||
|
||
describe 'full example' do | ||
it 'expects event to be publisher when published' do | ||
expect(publisher).to publish_event(publisher, :it_happened) | ||
|
||
publisher.execute | ||
end | ||
end | ||
end |