Skip to content

Commit

Permalink
updated generic presence test helpers with appropriate test names
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jun 14, 2024
1 parent 7634e6b commit 23c6fd2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spec/acceptance/realtime/presence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ def setup_test(method_name, args, options)
end

unless expected_state == :left
it 'raise an exception if the channel is detached' do
it "presence #{method_name} : raise an exception if the channel is detached" do
setup_test(method_name, args, options) do
client_one.connection.on :connected do
channel_client_one.attach do
channel_client_one.transition_state_machine :detaching
channel_client_one.once(:detached) do
presence_client_one.public_send(method_name, args).tap do |deferrable|
deferrable.callback { raise 'Get should not succeed' }
deferrable.callback { raise "presence #{method_name} should not succeed" }
deferrable.errback do |error|
expect(error).to be_a(Ably::Exceptions::InvalidState)
expect(error.message).to match(/Operation is not allowed when channel is in STATE.Detached/)
Expand All @@ -80,13 +80,13 @@ def setup_test(method_name, args, options)
end
end

it 'raise an exception if the channel becomes detached' do
it "presence #{method_name} : raise an exception if the channel becomes detached" do
setup_test(method_name, args, options) do
client_one.connection.on :connected do
channel_client_one.attach do
channel_client_one.transition_state_machine :detaching
presence_client_one.public_send(method_name, args).tap do |deferrable|
deferrable.callback { raise 'Get should not succeed' }
deferrable.callback { raise "presence #{method_name} should not succeed" }
deferrable.errback do |error|
expect(error).to be_a(Ably::Exceptions::InvalidState)
expect(error.message).to match(/Operation failed as channel transitioned to STATE.Detached/)
Expand All @@ -98,13 +98,13 @@ def setup_test(method_name, args, options)
end
end

it 'raise an exception if the channel is failed' do
it "presence #{method_name} : raise an exception if the channel is failed" do
setup_test(method_name, args, options) do
channel_client_one.attach do
channel_client_one.transition_state_machine :failed
expect(channel_client_one.state).to eq(:failed)
presence_client_one.public_send(method_name, args).tap do |deferrable|
deferrable.callback { raise 'Get should not succeed' }
deferrable.callback { raise "presence #{method_name} : Get should not succeed" }
deferrable.errback do |error|
expect(error).to be_a(Ably::Exceptions::InvalidState)
expect(error.message).to match(/Operation is not allowed when channel is in STATE.Failed/)
Expand All @@ -115,11 +115,11 @@ def setup_test(method_name, args, options)
end
end

it 'raise an exception if the channel becomes failed' do
it "presence #{method_name} : raise an exception if the channel becomes failed" do
setup_test(method_name, args, options) do
channel_client_one.attach do
presence_client_one.public_send(method_name, args).tap do |deferrable|
deferrable.callback { raise 'Get should not succeed' }
deferrable.callback { raise "presence #{method_name} : Get should not succeed" }
deferrable.errback do |error|
expect(error).to be_a(Ably::Exceptions::MessageDeliveryFailed)
stop_reactor
Expand Down

0 comments on commit 23c6fd2

Please sign in to comment.