mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Fix integration tests for Net HTTP Server.
This commit is contained in:
parent
f1538bf6df
commit
d4d6fbc782
3 changed files with 14 additions and 3 deletions
|
@ -1755,7 +1755,7 @@ module Sinatra
|
||||||
|
|
||||||
set :run, false # start server via at-exit hook?
|
set :run, false # start server via at-exit hook?
|
||||||
set :running, false # is the built-in server running now?
|
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 :bind, Proc.new { development? ? 'localhost' : '0.0.0.0' }
|
||||||
set :port, Integer(ENV['PORT'] || 4567)
|
set :port, Integer(ENV['PORT'] || 4567)
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ module IntegrationHelper
|
||||||
|
|
||||||
def installed?
|
def installed?
|
||||||
return @installed unless @installed.nil?
|
return @installed unless @installed.nil?
|
||||||
require server
|
s = server == 'HTTP' ? 'net/http/server' : server
|
||||||
|
require s
|
||||||
@installed = true
|
@installed = true
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
warn "#{server} is not installed, skipping integration tests"
|
warn "#{server} is not installed, skipping integration tests"
|
||||||
|
@ -134,6 +135,10 @@ module IntegrationHelper
|
||||||
name.to_s == "trinidad"
|
name.to_s == "trinidad"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def net_http_server?
|
||||||
|
name.to_s == 'HTTP'
|
||||||
|
end
|
||||||
|
|
||||||
def warnings
|
def warnings
|
||||||
log.scan(%r[(?:\(eval|lib/sinatra).*warning:.*$])
|
log.scan(%r[(?:\(eval|lib/sinatra).*warning:.*$])
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,13 @@ class IntegrationTest < Test::Unit::TestCase
|
||||||
random = "%064x" % Kernel.rand(2**256-1)
|
random = "%064x" % Kernel.rand(2**256-1)
|
||||||
server.get "/ping?x=#{random}"
|
server.get "/ping?x=#{random}"
|
||||||
count = server.log.scan("GET /ping?x=#{random}").count
|
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
|
end
|
||||||
|
|
||||||
it 'streams' do
|
it 'streams' do
|
||||||
|
|
Loading…
Reference in a new issue