Skip to content

Commit

Permalink
continuing DRYing up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markburns authored and stevegraham committed Apr 9, 2012
1 parent f73d3f1 commit f0f2ab1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions spec/integration/integration_spec.rb
Expand Up @@ -62,6 +62,11 @@ def stream websocket, messages
end
end

def em_stream
messages = []
yield websocket, messages
end

describe 'regular channels:' do
it 'pushes messages to interested websocket connections' do
messages = []
Expand Down Expand Up @@ -101,9 +106,9 @@ def stream websocket, messages
client1.send({ event: 'pusher:subscribe', data: { channel: 'MY_CHANNEL'} }.to_json)
end

client1.stream do |message|
stream(client1, client1_messages) do |message|
# if this is the first message to client 1 set up another connection from the same client
if client1_messages.empty?
if client1_messages.one?
client2 = new_websocket

client2.callback do
Expand All @@ -119,7 +124,6 @@ def stream websocket, messages
end
end
end
client1_messages << message
end
end

Expand Down

0 comments on commit f0f2ab1

Please sign in to comment.