spec/acceptance/realtime/presence_spec.rb in ably-0.8.4 vs spec/acceptance/realtime/presence_spec.rb in ably-0.8.5

- old
+ new

@@ -6,13 +6,13 @@ vary_by_protocol do let(:default_options) { { key: api_key, environment: environment, protocol: protocol } } let(:client_options) { default_options } - let(:anonymous_client) { Ably::Realtime::Client.new(client_options) } - let(:client_one) { Ably::Realtime::Client.new(client_options.merge(client_id: random_str)) } - let(:client_two) { Ably::Realtime::Client.new(client_options.merge(client_id: random_str)) } + let(:anonymous_client) { auto_close Ably::Realtime::Client.new(client_options) } + let(:client_one) { auto_close Ably::Realtime::Client.new(client_options.merge(client_id: random_str)) } + let(:client_two) { auto_close Ably::Realtime::Client.new(client_options.merge(client_id: random_str)) } let(:channel_name) { "presence-#{random_str(4)}" } let(:channel_anonymous_client) { anonymous_client.channel(channel_name) } let(:presence_anonymous_client) { channel_anonymous_client.presence } let(:channel_client_one) { client_one.channel(channel_name) } @@ -70,11 +70,11 @@ stop_reactor end end context 'when :queue_messages client option is false' do - let(:client_one) { Ably::Realtime::Client.new(default_options.merge(queue_messages: false, client_id: random_str)) } + let(:client_one) { auto_close Ably::Realtime::Client.new(default_options.merge(queue_messages: false, client_id: random_str)) } context 'and connection state initialized' do it 'raises an exception' do expect { presence_client_one.public_send(method_name, args) }.to raise_error Ably::Exceptions::MessageQueueingDisabled expect(client_one.connection).to be_initialized @@ -92,11 +92,11 @@ end end end context 'and connection state disconnected' do - let(:client_one) { Ably::Realtime::Client.new(default_options.merge(queue_messages: false, client_id: random_str, :log_level => :error)) } + let(:client_one) { auto_close Ably::Realtime::Client.new(default_options.merge(queue_messages: false, client_id: random_str, :log_level => :error)) } it 'raises an exception' do client_one.connection.once(:connected) do client_one.connection.once(:disconnected) do expect { presence_client_one.public_send(method_name, args) }.to raise_error Ably::Exceptions::MessageQueueingDisabled @@ -275,12 +275,11 @@ force_connection_failure client_one end presence_client_one.public_send(method_name, args).tap do |deferrable| deferrable.callback { raise 'Should not succeed' } - deferrable.errback do |presence, error| - expect(presence).to be_a(Ably::Realtime::Presence) + deferrable.errback do |error| expect(error).to be_kind_of(Ably::Exceptions::BaseAblyException) stop_reactor end end end @@ -661,11 +660,11 @@ stop_reactor end context 'without necessary capabilities to join presence' do let(:restricted_client) do - Ably::Realtime::Client.new(default_options.merge(key: restricted_api_key, log_level: :fatal)) + auto_close Ably::Realtime::Client.new(default_options.merge(key: restricted_api_key, log_level: :fatal)) end let(:restricted_channel) { restricted_client.channel("cansubscribe:channel") } let(:restricted_presence) { restricted_channel.presence } it 'calls the Deferrable errback on capabilities failure' do @@ -878,11 +877,11 @@ it_should_behave_like 'a public presence method', :enter_client, nil, 'client_id' context 'without necessary capabilities to enter on behalf of another client' do let(:restricted_client) do - Ably::Realtime::Client.new(default_options.merge(key: restricted_api_key, log_level: :fatal)) + auto_close Ably::Realtime::Client.new(default_options.merge(key: restricted_api_key, log_level: :fatal)) end let(:restricted_channel) { restricted_client.channel("cansubscribe:channel") } let(:restricted_presence) { restricted_channel.presence } it 'calls the Deferrable errback on capabilities failure' do @@ -1398,11 +1397,11 @@ context 'client_id with ASCII_8BIT' do let(:client_id) { random_str.encode(Encoding::ASCII_8BIT) } context 'in connection set up' do - let(:client_one) { Ably::Realtime::Client.new(default_options.merge(client_id: client_id)) } + let(:client_one) { auto_close Ably::Realtime::Client.new(default_options.merge(client_id: client_id)) } it 'is converted into UTF_8' do presence_client_one.enter presence_client_one.on(:entered) do |presence| expect(presence.client_id.encoding).to eql(Encoding::UTF_8) @@ -1411,10 +1410,10 @@ end end end context 'in channel options' do - let(:client_one) { Ably::Realtime::Client.new(default_options) } + let(:client_one) { auto_close Ably::Realtime::Client.new(default_options) } it 'is converted into UTF_8' do presence_client_one.enter(client_id: client_id) presence_client_one.on(:entered) do |presence| expect(presence.client_id.encoding).to eql(Encoding::UTF_8)