Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DRYing up integration spec

  • Loading branch information...
commit 5a068db35e486820f3283bbd45549e320a4f6a86 1 parent d64a9a3
@markburns markburns authored stevegraham committed
Showing with 5 additions and 24 deletions.
  1. +5 −24 spec/integration/integration_spec.rb
View
29 spec/integration/integration_spec.rb
@@ -11,8 +11,11 @@
let(:errback) { Proc.new { fail 'cannot connect to slanger. your box might be too slow. try increasing sleep value in the before block' } }
def new_websocket
- EM::HttpRequest.new("ws://0.0.0.0:8080/app/#{Pusher.key}?client=js&version=1.8.5").
- get :timeout => 0
+ uri = "ws://0.0.0.0:8080/app/#{Pusher.key}?client=js&version=1.8.5"
+
+ EM::HttpRequest.new(uri).get(:timeout => 0).tap do |ws|
+ ws.errback &errback
+ end
end
before(:each) do
@@ -51,8 +54,6 @@ def new_websocket
EM.run do
websocket = new_websocket
- websocket.errback &errback
-
websocket.stream do |message|
messages << message
if messages.length < 3
@@ -89,8 +90,6 @@ def new_websocket
client1.send({ event: 'pusher:subscribe', data: { channel: 'MY_CHANNEL'} }.to_json)
end
- client1.errback &errback
-
client1.stream do |message|
# if this is the first message to client 1 set up another connection from the same client
if client1_messages.empty?
@@ -100,8 +99,6 @@ def new_websocket
client2.send({ event: 'pusher:subscribe', data: { channel: 'MY_CHANNEL'} }.to_json)
end
- client2.errback &errback
-
client2.stream do |message|
client2_messages << message
if client2_messages.length < 3
@@ -132,8 +129,6 @@ def new_websocket
EM.run do
websocket = new_websocket
- websocket.errback &errback
-
websocket.stream do |message|
messages << JSON.parse(message)
if messages.empty?
@@ -163,8 +158,6 @@ def new_websocket
EM.run do
websocket = new_websocket
- websocket.errback &errback
-
websocket.stream do |message|
messages << JSON.parse(message)
if messages.length < 2
@@ -200,8 +193,6 @@ def new_websocket
end
- client1.errback &errback
-
client1.stream do |message|
client1_messages << JSON.parse(message)
if client1_messages.length < 2
@@ -216,8 +207,6 @@ def new_websocket
end
- client2.errback &errback
-
client2.stream do |message|
client2_messages << JSON.parse(message)
if client2_messages.length < 2
@@ -246,8 +235,6 @@ def new_websocket
EM.run do
websocket = new_websocket
- websocket.errback &errback
-
websocket.stream do |message|
messages << JSON.parse(message)
if messages.length < 2
@@ -279,8 +266,6 @@ def new_websocket
EM.run do
websocket = new_websocket
- websocket.errback &errback
-
websocket.stream do |message|
messages << JSON.parse(message)
if messages.length < 2
@@ -319,8 +304,6 @@ def new_websocket
EM.run do
websocket = new_websocket
- websocket.errback &errback
-
websocket.stream do |message|
messages << JSON.parse(message)
if messages.length < 2
@@ -355,7 +338,6 @@ def new_websocket
Thread.new do
EM.run do
user1 = new_websocket
- user1.errback &errback
user1.stream do |message|
messages << JSON.parse(message)
@@ -409,7 +391,6 @@ def new_websocket
Thread.new do
EM.run do
user1 = new_websocket
- user1.errback &errback
# setup our reference user
user1.stream do |message|
Please sign in to comment.
Something went wrong with that request. Please try again.