Merge pull request #671 from patriciomacadden/fix-integration-tests
Fix integration tests for Net HTTP Server.
This commit is contained in:
commit
9fbb92fea7
5
Gemfile
5
Gemfile
|
@ -75,12 +75,9 @@ if RUBY_ENGINE != 'jruby' or not ENV['TRAVIS']
|
|||
end
|
||||
gem 'RedCloth' unless RUBY_ENGINE == "macruby"
|
||||
gem 'puma'
|
||||
|
||||
## bluecloth is broken
|
||||
#gem 'bluecloth'
|
||||
end
|
||||
|
||||
gem 'net-http-server'
|
||||
gem 'net-http-server' unless RUBY_VERSION == '1.8.7' || RUBY_ENGINE =~ /jruby|rbx/
|
||||
|
||||
platforms :ruby_18, :jruby do
|
||||
gem 'json' unless RUBY_VERSION > '1.9' # is there a jruby but 1.8 only selector?
|
||||
|
|
|
@ -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"
|
||||
|
@ -102,7 +103,7 @@ module IntegrationHelper
|
|||
file, dir = RbConfig::CONFIG.values_at('ruby_install_name', 'bindir')
|
||||
cmd << File.expand_path(file, dir).inspect
|
||||
end
|
||||
cmd << "-w" unless thin?
|
||||
cmd << "-w" unless thin? || net_http_server?
|
||||
cmd << "-I" << File.expand_path('../../lib', __FILE__).inspect
|
||||
cmd << app_file.inspect << '-s' << server << '-o' << '127.0.0.1' << '-p' << port
|
||||
cmd << "-e" << environment.to_s << '2>&1'
|
||||
|
@ -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
|
||||
|
@ -76,7 +82,8 @@ class IntegrationTest < Test::Unit::TestCase
|
|||
with\sbackup\sfrom\s#{server}
|
||||
}ix
|
||||
|
||||
assert_match exp, server.log
|
||||
# because Net HTTP Server logs to $stderr by default
|
||||
assert_match exp, server.log unless server.net_http_server?
|
||||
end
|
||||
|
||||
it 'does not generate warnings' do
|
||||
|
|
Loading…
Reference in New Issue