Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Forked from kevinrutherford/event_bus_spec.rb
Last active December 17, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimweirich/5639114 to your computer and use it in GitHub Desktop.
Save jimweirich/5639114 to your computer and use it in GitHub Desktop.
describe 'EventBus methods cascade' do
Invariant { result.should == EventBus }
context 'clear' do
When(:result) { EventBus.clear }
Then { }
end
context 'publish' do
When(:result) { EventBus.publish('aa123bb', {}) }
Then { }
end
context 'subscribe' do
When(:result) { EventBus.subscribe('aa123bb', listener, :handler) }
Then { }
end
end
describe 'when called incorrectly' do
def it_fails
subscribe.should have_failed(ArgumentError)
end
context 'when specifying the event name' do
context 'must provide a method or a block' do
When(:subscribe) { EventBus.subscribe('blah', listener) }
Then { it_fails }
end
context 'cannot provide a method AND a block' do
When(:subscribe) { EventBus.subscribe('blah', listener, :handler) {|info| }}
Then { it_fails }
end
context 'must provide a block when no method is supplied' do
When(:subscribe) { EventBus.subscribe('blah') }
Then { it_fails }
end
end
context 'when specifying a listener object' do
context 'when a method is also provided' do
When(:subscribe) { EventBus.subscribe(listener, double) }
Then { it_fails }
end
context 'when a block is also provided' do
When(:subscribe) { EventBus.subscribe(listener) {|info| } }
Then { it_fails }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment