From f5265a3b6bb0d2fcbf8814ce0fa9ed0650992e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 12 Aug 2025 10:32:04 +0200 Subject: [PATCH] Use generic `Rackup::Handler.default` Move from specific `Rack::Handler::WEBrick` to more generic `Rackup::Handler.default`. This chooses the best available handler automatically. If more handlers are available, `RACKUP_HANDLER` environment variable could be used to override the default. ATM, Gemfile still specifies WEBrick, so this is the one which will be used. But replacing WEBrick by Puma should be as easy as updating the `Gemfile` --- spec/support/localhost_server.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/support/localhost_server.rb b/spec/support/localhost_server.rb index e04008e7..19082462 100644 --- a/spec/support/localhost_server.rb +++ b/spec/support/localhost_server.rb @@ -40,10 +40,10 @@ def find_available_port end def boot - # Use WEBrick since it's part of the ruby standard library and is available on all ruby interpreters. options = { :Port => port } - options.merge!(:AccessLog => [], :Logger => WEBrick::BasicLog.new(StringIO.new)) unless ENV['VERBOSE_SERVER'] - Rackup::Handler::WEBrick.run(Identify.new(@rack_app), **options) + options.merge!(:AccessLog => [], :Logger => Rack::NullLogger.new(@rack_app)) unless ENV['VERBOSE_SERVER'] + # This allows to use whatever web server is available. The Gemfile currently specifies WEBrick. + Rackup::Handler.default.run(Identify.new(@rack_app), **options) end def booted? @@ -58,7 +58,7 @@ def booted? def concurrently if should_use_subprocess? pid = Process.fork do - trap(:INT) { ::Rack::Handler::WEBrick.shutdown } + trap(:INT) { ::Rackup::Handler.default.shutdown } yield exit # manually exit; otherwise this sub-process will re-run the specs that haven't run yet. end