Skip to content

Commit

Permalink
Restore WEBrick support (#2067)
Browse files Browse the repository at this point in the history
4a55850 was a bit aggressive, it should not have dropped the "out of the
box" experience for Sinatra and WEBrick when you have the required gems
installed.
  • Loading branch information
dentarg authored Nov 19, 2024
1 parent 38cd687 commit 3f6c577
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ gem 'redcarpet', platforms: [:ruby]
gem 'simplecov', require: false
gem 'slim', '~> 5'
gem 'yajl-ruby', platforms: [:ruby]
gem 'webrick'

# sass-embedded depends on google-protobuf
# which fails to be installed on JRuby and TruffleRuby under aarch64
Expand Down
2 changes: 1 addition & 1 deletion lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ class << self
set :running_server, nil
set :handler_name, nil
set :traps, true
set :server, %w[]
set :server, %w[webrick]
set :bind, proc { development? ? 'localhost' : '0.0.0.0' }
set :port, Integer(ENV['PORT'] && !ENV['PORT'].empty? ? ENV['PORT'] : 4567)
set :quiet, false
Expand Down
4 changes: 4 additions & 0 deletions test/integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def command
end
end

def webrick?
name.to_s == "webrick"
end

def puma?
name.to_s == "puma"
end
Expand Down
4 changes: 3 additions & 1 deletion test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class IntegrationTest < Minitest::Test
count = server.log.scan("GET /ping?x=#{random}").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
next if server.trinidad?
next if server.webrick? or server.trinidad?
times, chunks = [Process.clock_gettime(Process::CLOCK_MONOTONIC)], []
server.get_stream do |chunk|
next if chunk.empty?
Expand Down
5 changes: 5 additions & 0 deletions test/settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ def pub; end
end

describe 'server' do
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')
Expand Down

0 comments on commit 3f6c577

Please sign in to comment.