1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Create integration_async_test for to be enable test with rainbows

This commit is contained in:
Ryuichi KAWAMATA 2020-08-04 16:35:46 +09:00
parent c0d4dd7418
commit 965c8b9c39
7 changed files with 83 additions and 39 deletions

View file

@ -0,0 +1,40 @@
require File.expand_path('../helper', __FILE__)
require File.expand_path('../integration_async_helper', __FILE__)
# These tests are like integration_test, but they test asynchronous streaming.
class IntegrationAsyncTest < Minitest::Test
extend IntegrationAsyncHelper
attr_accessor :server
it 'streams async' do
Timeout.timeout(3) do
chunks = []
server.get_stream '/async' do |chunk|
next if chunk.empty?
chunks << chunk
case chunk
when "hi!" then server.get "/send?msg=hello"
when "hello" then server.get "/send?close=1"
end
end
assert_equal ['hi!', 'hello'], chunks
end
end
it 'streams async from subclass' do
Timeout.timeout(3) do
chunks = []
server.get_stream '/subclass/async' do |chunk|
next if chunk.empty?
chunks << chunk
case chunk
when "hi!" then server.get "/subclass/send?msg=hello"
when "hello" then server.get "/subclass/send?close=1"
end
end
assert_equal ['hi!', 'hello'], chunks
end
end
end