spec/unit/modules/event_emitter_spec.rb in ably-0.1.6 vs spec/unit/modules/event_emitter_spec.rb in ably-0.2.0

- old
+ new

@@ -93,21 +93,35 @@ after do subject.trigger :message, msg end - it 'deletes matching callbacks' do - expect(obj).to_not receive(:received_message).with(msg) - subject.off(:message, &callback) - end + context 'with event names as arguments' do + it 'deletes matching callbacks' do + expect(obj).to_not receive(:received_message).with(msg) + subject.off(:message, &callback) + end - it 'deletes all callbacks if not block given' do - expect(obj).to_not receive(:received_message).with(msg) - subject.off(:message) + it 'deletes all callbacks if not block given' do + expect(obj).to_not receive(:received_message).with(msg) + subject.off(:message) + end + + it 'continues if the block does not exist' do + expect(obj).to receive(:received_message).with(msg) + subject.off(:message) { true } + end end - it 'continues if the block does not exist' do - expect(obj).to receive(:received_message).with(msg) - subject.off(:message) { true } + context 'without any event names' do + it 'deletes all matching callbacks' do + expect(obj).to_not receive(:received_message).with(msg) + subject.off(&callback) + end + + it 'deletes all callbacks if not block given' do + expect(obj).to_not receive(:received_message).with(msg) + subject.off + end end end end