Skip to content

Commit

Permalink
Added test to check for duplicate attach message sent or received
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jul 4, 2024
1 parent 07aadbd commit 47c55d7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/acceptance/realtime/channel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,43 @@ def disconnect_transport
end

context 'with connection state' do

sent_attach_messages = []
received_attached_messages = []
before(:each) do
sent_attach_messages = []
received_attached_messages = []
client.connection.__outgoing_protocol_msgbus__.subscribe do |message|
if message.action == :attach
sent_attach_messages << message
end
end
client.connection.__incoming_protocol_msgbus__.subscribe do |message|
if message.action == :attached
received_attached_messages << message
end
end
end

# Should send/receive attach/attached message only once
# No duplicates should be sent or received
let(:check_for_attach_messages) do
expect(sent_attach_messages.size).to eq(1)
expect(received_attached_messages.size).to eq(1)
end

it 'is initialized (#RTL4i)' do
expect(connection).to be_initialized
channel.attach do
check_for_attach_messages
stop_reactor
end
end

it 'is connecting (#RTL4i)' do
connection.once(:connecting) do
channel.attach do
check_for_attach_messages
stop_reactor
end
end
Expand All @@ -449,6 +476,7 @@ def disconnect_transport
connection.once(:connected) do
connection.once(:disconnected) do
channel.attach do
check_for_attach_messages
stop_reactor
end
end
Expand Down

0 comments on commit 47c55d7

Please sign in to comment.