spec/integrations/shared_examples.rb in firehose-1.1.0 vs spec/integrations/shared_examples.rb in firehose-1.1.1

- old
+ new

@@ -20,11 +20,10 @@ after(:each) { WebMock.enable! } let(:app) { Firehose::Rack::App.new } let(:messages) { (1..2000).map{|n| "msg-#{n}" } } let(:channel) { "/firehose/integration/#{Time.now.to_i}" } - let(:uri) { Firehose::Default::URI } let(:http_url) { "http://#{uri.host}:#{uri.port}#{channel}" } let(:ws_url) { "ws://#{uri.host}:#{uri.port}#{channel}" } it "should pub-sub http and websockets" do # Setup variables that we'll use after we turn off EM to validate our @@ -66,11 +65,17 @@ end # And test a web socket client too, at the same time. websocket = Proc.new do |cid| ws = Faye::WebSocket::Client.new(ws_url) + + ws.onopen = lambda do |event| + ws.send('{"message_sequence":0}') + end + ws.onmessage = lambda do |event| - received[cid] << event.data + frame = JSON.parse(event.data, :symbolize_names => true) + received[cid] << frame[:message] succeed.call cid unless received[cid].size < messages.size end ws.onclose = lambda do |event| ws = nil