Sha256: 9c133453c53fd771aaf2619ce49a225269300d4e5264b56f2dbae948c3e5e054

Contents?: true

Size: 1.27 KB

Versions: 35

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe Ably::Realtime::Client::IncomingMessageDispatcher, :api_private do
  let(:msgbus) do
    Ably::Util::PubSub.new
  end
  let(:connection) do
    instance_double('Ably::Realtime::Connection', __incoming_protocol_msgbus__: msgbus, configure_new: true, id: nil, set_connection_confirmed_alive: nil)
  end
  let(:client) do
    instance_double('Ably::Realtime::Client', channels: {})
  end

  subject { Ably::Realtime::Client::IncomingMessageDispatcher.new(client, connection) }

  context '#initialize' do
    it 'should subscribe to protocol messages from the connection' do
      expect(msgbus).to receive(:subscribe).with(:protocol_message).and_call_original
      subject
    end
  end

  context '#dispatch_protocol_message' do
    before { subject }

    it 'should raise an exception if a message is sent that is not a ProtocolMessage' do
      expect { msgbus.publish :protocol_message, nil }.to raise_error ArgumentError
    end

    it 'should warn if a message is received for a non-existent channel' do
      allow(subject).to receive_message_chain(:logger, :debug)
      expect(subject).to receive_message_chain(:logger, :warn)
      msgbus.publish :protocol_message, Ably::Models::ProtocolMessage.new(:action => :attached, channel: 'unknown')
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
ably-rest-1.1.2.rc1 lib/submodules/ably-ruby/spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.1.1 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-rest-1.1.0 lib/submodules/ably-ruby/spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.1.0 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.7 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-rest-1.0.6 lib/submodules/ably-ruby/spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.6 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-rest-1.0.5 lib/submodules/ably-ruby/spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.5 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.4 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.3 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.2 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.1 spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-rest-1.0.0 lib/submodules/ably-ruby/spec/unit/realtime/incoming_message_dispatcher_spec.rb
ably-1.0.0 spec/unit/realtime/incoming_message_dispatcher_spec.rb