Permalink
Browse files

further spec DRYed up with em_stream method call

  • Loading branch information...
markburns authored and stevegraham committed Apr 7, 2012
1 parent dc0718a commit d885a2c95f5962cecdfdf70cfc56bcecab8b66d8
Showing with 10 additions and 13 deletions.
  1. +10 −13 spec/integration/integration_spec.rb
@@ -148,7 +148,9 @@ def stream websocket, messages
messages = em_stream do |websocket, messages|
if messages.empty?
auth = Pusher['private-channel'].authenticate(messages.first['data']['socket_id'])[:auth]
websocket.send({ event: 'pusher:subscribe', data: { channel: 'private-channel', auth: auth } }.to_json)
websocket.send({ event: 'pusher:subscribe',
data: { channel: 'private-channel',
auth: auth } }.to_json)
else
EM.stop
end
@@ -164,19 +166,14 @@ def stream websocket, messages
context 'with bogus authentication credentials:' do
it 'sends back an error message' do
messages = []
em_thread do
websocket = new_websocket
stream(websocket, messages) do |message|
if messages.length < 2
websocket.send({ event: 'pusher:subscribe', data: { channel: 'private-channel', auth: 'bogus' } }.to_json)
else
EM.stop
end
messages = em_stream do |websocket, messages|
if messages.length < 2
websocket.send({ event: 'pusher:subscribe',
data: { channel: 'private-channel',
auth: 'bogus' } }.to_json)
else
EM.stop
end
end
# Slanger should send an object denoting connection was succesfully established

0 comments on commit d885a2c

Please sign in to comment.