spec/middleware_spec.rb in rasti-web-broadcaster-1.1.2 vs spec/middleware_spec.rb in rasti-web-broadcaster-2.0.0
- old
+ new
@@ -45,11 +45,11 @@
'HTTP_HOST' => 'localhost'
event_source = nil
events = []
- env['async.callback'] = proc do |(status, headers, body)|
+ env['async.callback'] = proc do |(_status, _headers, body)|
event_source = body.instance_variable_get(:@socket_object)
body.each { |e| events << e }
end
Rasti::Web::Broadcaster.publish 'channel_1', data: 'message 0'
@@ -58,17 +58,18 @@
Rasti::Web::Broadcaster.publish 'channel_1', data: 'message 1', event: 'event_1', id: 1
Rasti::Web::Broadcaster.publish 'channel_2', data: 'message 2'
Rasti::Web::Broadcaster.publish 'channel_1', data: 'message 3'
- wait_for { events.count == 3 }
+ wait_for { events.count == 4 }
event_source.close
events.must_equal [
event_headers,
event_for(data: 'message 1', event: 'event_1', id: 1),
- event_for(data: 'message 3')
+ event_for(data: 'message 3'),
+ event_for(event: Rasti::Web::Broadcaster::KEEP_ALIVE_EVENT)
]
end
it 'Ignore normal request' do
env = Rack::MockRequest.env_for '/resource/123'
\ No newline at end of file