be smarter about servers

This commit is contained in:
Konstantin Haase 2012-05-13 20:59:49 +02:00
parent 5a8080a077
commit 6ec5234517
3 changed files with 29 additions and 4 deletions

View File

@ -72,6 +72,8 @@ if RUBY_ENGINE != 'jruby' or not ENV['TRAVIS']
#gem 'bluecloth'
end
gem 'net-http-server'
platforms :ruby_18, :jruby do
gem 'json' unless RUBY_VERSION > '1.9' # is there a jruby but 1.8 only selector?
end

View File

@ -1609,10 +1609,22 @@ module Sinatra
set :run, false # start server via at-exit hook?
set :running, false # is the built-in server running now?
set :server, %w[thin puma mongrel webrick]
set :server, %w[http webrick]
set :bind, '0.0.0.0'
set :port, 4567
ruby_engine = defined?(RUBY_ENGINE) && RUBY_ENGINE
if ruby_engine == 'macruby'
server.unshift 'controll_tower'
else
server.unshift 'mongrel' if ruby_engine.nil?
server.unshift 'puma' if ruby_engine != 'rbx'
server.unshift 'thin' if ruby_engine != 'jruby'
server.unshift 'puma' if ruby_engine == 'rbx'
server.unshift 'trinidat' if ruby_engine =='jruby'
end
set :absolute_redirects, true
set :prefixed_redirects, false
set :empty_path_info, nil

View File

@ -422,9 +422,20 @@ class SettingsTest < Test::Unit::TestCase
end
describe 'server' do
it 'is one of thin, puma, mongrel, webrick' do
assert_equal %w[thin puma mongrel webrick], @base.server
assert_equal %w[thin puma mongrel webrick], @application.server
it 'includes webrick' do
assert @base.server.include?('webrick')
assert @application.server.include?('webrick')
end
it 'includes puma' do
assert @base.server.include?('puma')
assert @application.server.include?('puma')
end
it 'includes thin' do
next if RUBY_ENGINE == 'jruby'
assert @base.server.include?('thin')
assert @application.server.include?('thin')
end
end