Fix integration tests for Net HTTP Server.
This commit is contained in:
parent
f1538bf6df
commit
d4d6fbc782
|
@ -1755,7 +1755,7 @@ module Sinatra
|
|||
|
||||
set :run, false # start server via at-exit hook?
|
||||
set :running, false # is the built-in server running now?
|
||||
set :server, %w[http webrick]
|
||||
set :server, %w[HTTP webrick]
|
||||
set :bind, Proc.new { development? ? 'localhost' : '0.0.0.0' }
|
||||
set :port, Integer(ENV['PORT'] || 4567)
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ module IntegrationHelper
|
|||
|
||||
def installed?
|
||||
return @installed unless @installed.nil?
|
||||
require server
|
||||
s = server == 'HTTP' ? 'net/http/server' : server
|
||||
require s
|
||||
@installed = true
|
||||
rescue LoadError
|
||||
warn "#{server} is not installed, skipping integration tests"
|
||||
|
@ -134,6 +135,10 @@ module IntegrationHelper
|
|||
name.to_s == "trinidad"
|
||||
end
|
||||
|
||||
def net_http_server?
|
||||
name.to_s == 'HTTP'
|
||||
end
|
||||
|
||||
def warnings
|
||||
log.scan(%r[(?:\(eval|lib/sinatra).*warning:.*$])
|
||||
end
|
||||
|
|
|
@ -17,7 +17,13 @@ class IntegrationTest < Test::Unit::TestCase
|
|||
random = "%064x" % Kernel.rand(2**256-1)
|
||||
server.get "/ping?x=#{random}"
|
||||
count = server.log.scan("GET /ping?x=#{random}").count
|
||||
server.webrick? ? assert(count > 0) : assert_equal(1, count)
|
||||
if server.net_http_server?
|
||||
assert_equal 0, count
|
||||
elsif server.webrick?
|
||||
assert(count > 0)
|
||||
else
|
||||
assert_equal(1, count)
|
||||
end
|
||||
end
|
||||
|
||||
it 'streams' do
|
||||
|
|
Loading…
Reference in New Issue