spec/acceptance/realtime/connection_failures_spec.rb in ably-1.2.4 vs spec/acceptance/realtime/connection_failures_spec.rb in ably-1.2.6
- old
+ new
@@ -745,12 +745,10 @@
connection.once(:connected) do
connection_id = connection.id
resumed_connection = false
connection.once(:disconnected) do
- disconnected_at = Time.now
-
allow(connection).to receive(:time_since_connection_confirmed_alive?).and_return(connection.connection_state_ttl + 1)
# Make sure the next connect does not have the resume param
allow(EventMachine).to receive(:connect).and_wrap_original do |original, *args, &block|
url = args[4]
@@ -779,12 +777,10 @@
connection.once(:connected) do
connection_id = connection.id
resumed_with_clean_connection = false
connection.once(:disconnected) do
- disconnected_at = Time.now
-
pseudo_time_passed = connection.connection_state_ttl + connection.details.max_idle_interval + 1
allow(connection).to receive(:time_since_connection_confirmed_alive?).and_return(pseudo_time_passed)
# Make sure the next connect does not have the resume param
allow(EventMachine).to receive(:connect).and_wrap_original do |original, *args, &block|
@@ -813,18 +809,15 @@
connection_id = connection.id
resumed_with_clean_connection = false
channel_emitted_an_attached = false
channel.attach do
- channel.once(:attached) do |channel_state_change|
- expect(channel_state_change.resumed).to be_falsey
+ channel.once(:attached) do
channel_emitted_an_attached = true
end
connection.once(:disconnected) do
- disconnected_at = Time.now
-
pseudo_time_passed = connection.connection_state_ttl + connection.details.max_idle_interval + 1
allow(connection).to receive(:time_since_connection_confirmed_alive?).and_return(pseudo_time_passed)
# Make sure the next connect does not have the resume param
allow(EventMachine).to receive(:connect).and_wrap_original do |original, *args, &block|
@@ -953,11 +946,11 @@
it 'retains connection_id and updates the connection_key (#RTN15e, #RTN16d)' do
connection.once(:connected) do
previous_connection_id = connection.id
connection.transport.close_connection_after_writing
- expect(connection).to receive(:configure_new).with(previous_connection_id, anything, anything).and_call_original
+ expect(connection).to receive(:configure_new).with(previous_connection_id, anything).and_call_original
connection.once(:connected) do
expect(connection.key).to_not be_nil
expect(connection.id).to eql(previous_connection_id)
stop_reactor
@@ -1006,20 +999,10 @@
end
end
end
end
- it 'executes the resume callback', api_private: true do
- channel.attach do
- connection.transport.close_connection_after_writing
- connection.on_resume do
- expect(connection).to be_connected
- stop_reactor
- end
- end
- end
-
context 'when messages were published whilst the client was disconnected' do
it 'receives the messages published whilst offline' do
messages_received = false
channel.subscribe('event') do |message|
@@ -1087,11 +1070,11 @@
context 'because the connection_key is not or no longer valid' do
let(:channel) { client.channel(random_str) }
def kill_connection_transport_and_prevent_valid_resume
connection.transport.close_connection_after_writing
- connection.configure_new '0123456789abcdef', 'wVIsgTHAB1UvXh7z-1991d8586', -1 # force the resume connection key to be invalid
+ connection.configure_new '0123456789abcdef', '0123456789abcdef-99' # force the resume connection key to be invalid
end
it 'updates the connection_id and connection_key' do
connection.once(:connected) do
previous_connection_id = connection.id
@@ -1120,11 +1103,11 @@
channel.publish("foo").errback do
failed_messages << channel
end
channel.on(:attaching) do |channel_state_change|
error = channel_state_change.reason
- expect(error.message).to match(/Unable to recover connection/i)
+ expect(error.message).to match(/Invalid connection key/i)
reattaching_channels << channel
end
channel.on(:attached) do
attached_channels << channel
next unless attached_channels.count == channel_count
@@ -1220,13 +1203,13 @@
end
it 'sets the error reason on each channel' do
channel.attach do
channel.on(:attaching) do |state_change|
- expect(state_change.reason.message).to match(/Unable to recover connection/i)
- expect(state_change.reason.code).to eql(80008)
- expect(channel.error_reason.code).to eql(80008)
+ expect(state_change.reason.message).to match(/Invalid connection key/i)
+ expect(state_change.reason.code).to eql(80018)
+ expect(channel.error_reason.code).to eql(80018)
channel.on(:attached) do |state_change|
stop_reactor
end
end
@@ -1373,10 +1356,10 @@
normal_token
end
end)
end
- xit 'triggers a re-authentication and then resumes the connection' do
+ it 'triggers a re-authentication and then resumes the connection' do
# [PENDING] After sandbox env update connection isn't found and a new connection is created. Spec fails
#
connection.once(:connected) do
connection_id = connection.id