Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion spec/acceptance/realtime/connection_failures_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def fail_if_suspended_or_failed
end

context 'when DISCONNECTED ProtocolMessage received from the server' do
it 'reconnects automatically and immediately' do
it 'reconnects automatically and immediately (#RTN15a)' do
fail_if_suspended_or_failed

connection.once(:connected) do
Expand All @@ -590,6 +590,30 @@ def fail_if_suspended_or_failed
end
end

context 'when protocolMessage contains token error' do
context "library does not have a means to renew the token (#RTN15h1)" do
let(:auth_url) { 'https://echo.ably.io/createJWT' }
let(:token) { Faraday.get("#{auth_url}?keyName=#{key_name}&keySecret=#{key_secret}").body }
let(:client_options) { default_options.merge(token: token, log_level: :none) }

let(:error_message) { 'error_message' }

it 'moves connection state to failed' do
connection.on(:failed) do |connection_state_change|
expect(connection.error_reason.message).to eq(error_message)
stop_reactor
end

connection.on(:connected) do
protocol_message = Ably::Models::ProtocolMessage.new(action: Ably::Models::ProtocolMessage::ACTION.Disconnected.to_i, error: { code: 40140, message: error_message })
connection.__incoming_protocol_msgbus__.publish :protocol_message, protocol_message
end

connection.connect
end
end
end

context 'connection state freshness is monitored' do
it 'resumes connections when disconnected within the connection_state_ttl period (#RTN15g)' do
connection.once(:connected) do
Expand Down