Last active
December 17, 2015 16:28
-
-
Save kevinrutherford/5638531 to your computer and use it in GitHub Desktop.
How can I remove the duplicated Then clauses in these specs?
This file contains hidden or 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
context 'EventBus methods cascade' do | |
context 'clear' do | |
When(:result) { EventBus.clear } | |
Then { result.should == EventBus } | |
end | |
context 'publish' do | |
When(:result) { EventBus.publish('aa123bb', {}) } | |
Then { result.should == EventBus } | |
end | |
context 'subscribe' do | |
When(:result) { EventBus.subscribe('aa123bb', listener, :handler) } | |
Then { result.should == EventBus } | |
end | |
end |
This file contains hidden or 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
context 'when called incorrectly' do | |
context 'when specifying the event name' do | |
context 'must provide a method or a block' do | |
When(:subscribe) { EventBus.subscribe('blah', listener) } | |
Then { subscribe.should have_failed(ArgumentError) } | |
end | |
context 'cannot provide a method AND a block' do | |
When(:subscribe) { EventBus.subscribe('blah', listener, :handler) {|info| }} | |
Then { subscribe.should have_failed(ArgumentError) } | |
end | |
context 'must provide a block when no method is supplied' do | |
When(:subscribe) { EventBus.subscribe('blah') } | |
Then { subscribe.should have_failed(ArgumentError) } | |
end | |
end | |
context 'when specifying a listener object' do | |
context 'when a method is also provided' do | |
When(:subscribe) { EventBus.subscribe(listener, double) } | |
Then { subscribe.should have_failed(ArgumentError) } | |
end | |
context 'when a block is also provided' do | |
When(:subscribe) { EventBus.subscribe(listener) {|info| } } | |
Then { subscribe.should have_failed(ArgumentError) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment