spec/unit/util/pub_sub_spec.rb in ably-0.6.2 vs spec/unit/util/pub_sub_spec.rb in ably-0.7.0

- old
+ new

@@ -6,27 +6,27 @@ let(:msg) { double('message') } subject { Ably::Util::PubSub.new(options) } context 'event fan out' do - specify 'allows publishing to more than on subscriber' do + specify '#publish allows publishing to more than on subscriber' do expect(obj).to receive(:received_message).with(msg).twice 2.times do subject.subscribe(:message) { |msg| obj.received_message msg } end subject.publish :message, msg end - it 'sends only messages to matching event names' do + it '#publish sends only messages to #subscribe callbacks matching event names' do expect(obj).to receive(:received_message).with(msg).once subject.subscribe(:valid) { |msg| obj.received_message msg } subject.publish :valid, msg subject.publish :ignored, msg subject.publish 'valid', msg end - context 'with coercion' do + context 'with coercion', api_private: true do let(:options) do { coerce_into: Proc.new { |event| String(event) } } end it 'calls the provided proc to coerce the event name' do @@ -46,19 +46,19 @@ expect { exception_pubsub.publish :fail }.to raise_error KeyError end end end - context 'without coercion' do + context 'without coercion', api_private: true do it 'only matches event names on type matches' do expect(obj).to_not receive(:received_message).with(msg) subject.subscribe('valid') { |msg| obj.received_message msg } subject.publish :valid, msg end end end - context '#off' do + context '#unsubscribe' do let(:callback) { Proc.new { |msg| obj.received_message msg } } before do subject.subscribe(:message, &callback) end