2011-10-31 21:40:22 +00:00
|
|
|
require File.expand_path('../helper', __FILE__)
|
2012-03-07 21:17:58 +00:00
|
|
|
require File.expand_path('../integration_helper', __FILE__)
|
2011-10-31 21:40:22 +00:00
|
|
|
|
2012-03-07 22:05:37 +00:00
|
|
|
# These tests start a real server and talk to it over TCP.
|
|
|
|
# Every test runs with every detected server.
|
|
|
|
#
|
|
|
|
# See test/integration/app.rb for the code of the app we test against.
|
2011-10-31 21:40:22 +00:00
|
|
|
class IntegrationTest < Test::Unit::TestCase
|
2012-03-07 21:17:58 +00:00
|
|
|
extend IntegrationHelper
|
|
|
|
attr_accessor :server
|
2011-11-06 12:17:42 +00:00
|
|
|
|
2012-03-07 21:17:58 +00:00
|
|
|
it('sets the app_file') { assert_equal server.app_file, server.get("/app_file") }
|
|
|
|
it('only extends main') { assert_equal "true", server.get("/mainonly") }
|
2011-10-31 21:59:09 +00:00
|
|
|
|
2012-03-07 21:17:58 +00:00
|
|
|
it 'logs once in development mode' do
|
|
|
|
random = "%064x" % Kernel.rand(2**256-1)
|
|
|
|
server.get "/ping?x=#{random}"
|
|
|
|
assert_equal 1, server.log.scan("GET /ping?x=#{random}").count
|
2011-10-31 21:59:09 +00:00
|
|
|
end
|
2011-11-05 13:46:14 +00:00
|
|
|
|
2012-03-07 21:58:59 +00:00
|
|
|
it 'streams' do
|
|
|
|
next if server.name == "webrick"
|
2012-03-08 06:48:30 +00:00
|
|
|
times, chunks = [Time.now], []
|
2012-03-07 21:58:59 +00:00
|
|
|
server.get_stream do |chunk|
|
2012-03-08 06:48:30 +00:00
|
|
|
next if chunk.empty?
|
2012-03-07 21:58:59 +00:00
|
|
|
chunks << chunk
|
|
|
|
times << Time.now
|
|
|
|
end
|
2012-03-08 06:48:30 +00:00
|
|
|
assert_equal ["a", "b"], chunks
|
2012-03-07 21:58:59 +00:00
|
|
|
assert times[1] - times[0] < 1
|
|
|
|
assert times[2] - times[1] > 1
|
|
|
|
end
|
|
|
|
|
2012-03-07 21:17:58 +00:00
|
|
|
it 'starts the correct server' do
|
|
|
|
exp = %r{
|
|
|
|
==\sSinatra/#{Sinatra::VERSION}\s
|
|
|
|
has\staken\sthe\sstage\son\s\d+\sfor\sdevelopment\s
|
|
|
|
with\sbackup\sfrom\s#{server}
|
|
|
|
}ix
|
2012-03-07 16:15:05 +00:00
|
|
|
|
2012-03-07 21:17:58 +00:00
|
|
|
assert_match exp, server.log
|
2012-03-07 16:15:05 +00:00
|
|
|
end
|
2012-03-07 21:17:58 +00:00
|
|
|
end
|