Skip to content

Commit

Permalink
chore(test): Running with Rack > 3.1 gives error uninitialized consta…
Browse files Browse the repository at this point in the history
…nt Rack::Handler
  • Loading branch information
YOU54F committed Jun 15, 2024
1 parent 1bbc294 commit f895d5e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ group :test do
gem 'faraday', '~>2.0'
gem 'faraday-retry', '~>2.0'
gem 'rackup', '~> 2.1'
gem 'rack', '>= 3.0', '< 4.0'
end
12 changes: 12 additions & 0 deletions spec/lib/rack/webrick.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Rack
module Handler
begin
require 'rack/handler/webrick'
WEBrick = Class.new(Rack::Handler::WEBrick)
rescue LoadError
require 'rackup/handler/webrick'
WEBrick = Class.new(Rackup::Handler::WEBrick)
end
end
end

19 changes: 14 additions & 5 deletions spec/support/ssl_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ def webrick_opts port
require "webrick"
require "webrick/https"
require "rack"
require "rackup/handler/webrick"
begin
# For rack <= 3.0.x
require 'rack/handler/webrick'
opts = webrick_opts(4444)
Rack::Handler::WEBrick.run(app, **opts) do |server|
@server = server
end
rescue LoadError
# For rack >= 3.1.x
require 'rackup/handler/webrick'
opts = webrick_opts(4444)

opts = webrick_opts(4444)

Rack::Handler::WEBrick.run(app, **opts) do |server|
@server = server
Rackup::Handler::WEBrick.run(app, **opts) do |server|
@server = server
end
end
end

0 comments on commit f895d5e

Please sign in to comment.