lib/submodules/ably-ruby/spec/acceptance/realtime/presence_spec.rb in ably-rest-1.0.5 vs lib/submodules/ably-ruby/spec/acceptance/realtime/presence_spec.rb in ably-rest-1.0.6
- old
+ new
@@ -12,11 +12,11 @@
let(:client_one_id) { random_str }
let(:client_one) { auto_close Ably::Realtime::Client.new(client_options.merge(client_id: client_one_id)) }
let(:client_two_id) { random_str }
let(:client_two) { auto_close Ably::Realtime::Client.new(client_options.merge(client_id: client_two_id)) }
- let(:wildcard_token) { Proc.new { Ably::Rest::Client.new(client_options).auth.request_token(client_id: '*') } }
+ let(:wildcard_token) { lambda { |token_params| Ably::Rest::Client.new(client_options).auth.request_token(client_id: '*') } }
let(:channel_name) { "presence-#{random_str(4)}" }
let(:channel_anonymous_client) { anonymous_client.channel(channel_name) }
let(:presence_anonymous_client) { channel_anonymous_client.presence }
let(:channel_client_one) { client_one.channel(channel_name) }
let(:channel_rest_client_one) { client_one.rest_client.channel(channel_name) }
@@ -1352,11 +1352,11 @@
presence_anonymous_client.subscribe(:update) do |presence|
expect(presence.data).to eql(data)
clients << presence
next unless clients.count == 5
- wait_until(proc { updated_callback_count == 5 }) do
+ wait_until(lambda { updated_callback_count == 5 }) do
expect(clients.map(&:client_id).uniq.count).to eql(5)
expect(updated_callback_count).to eql(5)
stop_reactor
end
end
@@ -1386,11 +1386,11 @@
presence_anonymous_client.subscribe(:enter) do |presence|
expect(presence.data).to eql(data)
clients << presence
next unless clients.count == 5
- wait_until(proc { updated_callback_count == 5 }) do
+ wait_until(lambda { updated_callback_count == 5 }) do
expect(clients.map(&:client_id).uniq.count).to eql(5)
expect(updated_callback_count).to eql(5)
stop_reactor
end
end
@@ -1418,11 +1418,11 @@
presence_anonymous_client.subscribe(:leave) do |presence|
expect(presence.data).to eql(data)
clients << presence
next unless clients.count == 5
- wait_until(proc { left_callback_count == 5 }) do
+ wait_until(lambda { left_callback_count == 5 }) do
expect(clients.map(&:client_id).uniq.count).to eql(5)
expect(left_callback_count).to eql(5)
stop_reactor
end
end
@@ -1440,11 +1440,11 @@
presence_anonymous_client.subscribe(:leave) do |presence|
expect(presence.data).to be_nil
clients << presence
next unless clients.count == 5
- wait_until(proc { left_callback_count == 5 }) do
+ wait_until(lambda { left_callback_count == 5 }) do
expect(clients.map(&:client_id).uniq.count).to eql(5)
expect(left_callback_count).to eql(5)
stop_reactor
end
end
@@ -1787,11 +1787,11 @@
presence_client_two.subscribe(:enter) do
clients_entered[:client_two] += 1
end
- wait_until(proc { clients_entered[:client_one] + clients_entered[:client_two] == total_members * 2 }) do
+ wait_until(lambda { clients_entered[:client_one] + clients_entered[:client_two] == total_members * 2 }) do
presence_anonymous_client.get(wait_for_sync: true) do |anonymous_members|
expect(anonymous_members.count).to eq(total_members)
expect(anonymous_members.map(&:client_id).uniq.count).to eq(total_members)
presence_client_one.get(wait_for_sync: true) do |client_one_members|
@@ -1884,11 +1884,11 @@
context '#unsubscribe' do
context 'with no arguments' do
it 'removes the callback for all presence events' do
when_all(channel_client_one.attach, channel_client_two.attach) do
- subscribe_callback = proc { raise 'Should not be called' }
+ subscribe_callback = lambda { raise 'Should not be called' }
presence_client_two.subscribe(&subscribe_callback)
presence_client_two.unsubscribe(&subscribe_callback)
presence_client_one.enter
presence_client_one.update
@@ -1902,11 +1902,11 @@
end
context 'with event name' do
it 'removes the callback for specified presence event' do
when_all(channel_client_one.attach, channel_client_two.attach) do
- subscribe_callback = proc { raise 'Should not be called' }
+ subscribe_callback = lambda { raise 'Should not be called' }
presence_client_two.subscribe :leave, &subscribe_callback
presence_client_two.unsubscribe :leave, &subscribe_callback
presence_client_one.enter do
presence_client_one.leave do
@@ -2335,11 +2335,11 @@
context 'when the client does not have presence subscribe privileges but is present on the channel' do
let(:present_only_capability) do
{ channel_name => ["presence"] }
end
- let(:present_only_callback) { Proc.new { Ably::Rest::Client.new(client_options).auth.request_token(client_id: '*', capability: present_only_capability) } }
+ let(:present_only_callback) { lambda { |token_params| Ably::Rest::Client.new(client_options).auth.request_token(client_id: '*', capability: present_only_capability) } }
let(:client_one) { auto_close Ably::Realtime::Client.new(client_options.merge(auth_callback: present_only_callback)) }
it 'receives presence updates for all presence events generated by the current connection and the presence map is kept up to date (#RTP17a)' do
skip 'This functionality is not yet in sandbox, see https://github.com/ably/realtime/issues/656'
@@ -2749,10 +2749,10 @@
end
end
context 'channel transitions to the SUSPENDED state' do
let(:auth_callback) do
- Proc.new do
+ lambda do |token_params|
# Pause to allow presence updates to occur whilst disconnected
sleep 1
Ably::Rest::Client.new(client_options).auth.request_token
end
end