aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/client_test.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-01-28 21:19:10 +1030
committerMatthew Draper <matthew@trebex.net>2016-01-30 03:46:37 +1030
commit0b94afb0757e02deccced2d85b8478b78f269e0b (patch)
treed8afbaa85d6f82a261b8fd259ec049d8959b1445 /actioncable/test/client_test.rb
parent786ed1b3ad8eeddb911211b67031016730ed55c8 (diff)
downloadrails-0b94afb0757e02deccced2d85b8478b78f269e0b.tar.gz
rails-0b94afb0757e02deccced2d85b8478b78f269e0b.tar.bz2
rails-0b94afb0757e02deccced2d85b8478b78f269e0b.zip
Be more patient while gathering the expected responses
Diffstat (limited to 'actioncable/test/client_test.rb')
-rw-r--r--actioncable/test/client_test.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/actioncable/test/client_test.rb b/actioncable/test/client_test.rb
index 7617e93426..66fa79afd6 100644
--- a/actioncable/test/client_test.rb
+++ b/actioncable/test/client_test.rb
@@ -154,10 +154,10 @@ class ClientTest < ActionCable::TestCase
msg
end
- def read_messages
+ def read_messages(expected_size = 0)
list = []
loop do
- @has_messages.wait(WAIT_WHEN_NOT_EXPECTING_EVENT)
+ @has_messages.wait(list.size < expected_size ? WAIT_WHEN_EXPECTING_EVENT : WAIT_WHEN_NOT_EXPECTING_EVENT)
if @has_messages.set?
list << read_message
else
@@ -222,8 +222,7 @@ class ClientTest < ActionCable::TestCase
barrier_1.wait WAIT_WHEN_EXPECTING_EVENT
c.send_message command: 'message', identifier: JSON.dump(channel: 'EchoChannel'), data: JSON.dump(action: 'bulk', message: 'hello')
barrier_2.wait WAIT_WHEN_EXPECTING_EVENT
- sleep 1
- assert_equal clients.size, c.read_messages.size
+ assert_equal clients.size, c.read_messages(clients.size).size
} }.each(&:wait!)
clients.map {|c| Concurrent::Future.execute { c.close } }.each(&:wait!)