spec/acceptance/realtime/connection_failures_spec.rb in ably-0.8.3 vs spec/acceptance/realtime/connection_failures_spec.rb in ably-0.8.4
- old
+ new
@@ -22,11 +22,12 @@
context 'when API key is invalid' do
context 'with invalid app part of the key' do
let(:invalid_key) { 'not_an_app.invalid_key_name:invalid_key_value' }
it 'enters the failed state and returns a not found error' do
- connection.on(:failed) do |error|
+ connection.on(:failed) do |connection_state_change|
+ error = connection_state_change.reason
expect(connection.state).to eq(:failed)
# TODO: Check error type is an InvalidToken exception
expect(error.status).to eq(404)
expect(error.code).to eq(40400) # not found
stop_reactor
@@ -36,11 +37,12 @@
context 'with invalid key name part of the key' do
let(:invalid_key) { "#{app_id}.invalid_key_name:invalid_key_value" }
it 'enters the failed state and returns an authorization error' do
- connection.on(:failed) do |error|
+ connection.on(:failed) do |connection_state_change|
+ error = connection_state_change.reason
expect(connection.state).to eq(:failed)
# TODO: Check error type is a TokenNotFOund exception
expect(error.status).to eq(401)
expect(error.code).to eq(40400) # not found
stop_reactor
@@ -180,11 +182,12 @@
end
context '#error_reason' do
[:disconnected, :suspended, :failed].each do |state|
it "contains the error when state is #{state}" do
- connection.on(state) do |error|
+ connection.on(state) do |connection_state_change|
+ error = connection_state_change.reason
expect(connection.error_reason).to eq(error)
expect(connection.error_reason.code).to eql(80000)
stop_reactor
end
end
@@ -486,10 +489,11 @@
channel_count = 10
channels = channel_count.times.map { |index| client.channel("channel-#{index}") }
when_all(*channels.map(&:attach)) do
detached_channels = []
channels.each do |channel|
- channel.on(:detached) do |error|
+ channel.on(:detached) do |channel_state_change|
+ error = channel_state_change.reason
expect(error.message).to match(/Invalid connection key/i)
detached_channels << channel
next unless detached_channels.count == channel_count
expect(detached_channels.count).to eql(channel_count)
stop_reactor