Skip to content

Commit

Permalink
Be more patient while gathering the expected responses
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewd committed Jan 29, 2016
1 parent 786ed1b commit 0b94afb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions actioncable/test/client_test.rb
Expand Up @@ -154,10 +154,10 @@ def read_message
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
Expand Down Expand Up @@ -222,8 +222,7 @@ def test_interacting_clients
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!)
Expand Down

0 comments on commit 0b94afb

Please sign in to comment.