Add support for Rack 3 (fix "unable to connect") #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Upgrading to Rack 3+ causes calls to
Capybara::Webmock.start
to fail with "RuntimeError: Unable to connect to capybara-webmock proxy on 9292" (followed by "EOFError: end of file reached" for subsequent tests in the rspec run).That happens because this gem's config.ru file calls
Rack::Handler::WEBrick
, which no longer exists as of Rack 3. It has been moved to Rackup (Rackup::Handler::WEBrick
).Solution
This modifies config.ru to look for a new Rackup handler before falling back to an old Rack handler.
This uses the same syntax used in capybara since 2023-10-08.
We missed the deprecation period because the warnings emitted in stdout don't get displayed. Likewise, now this is raising an error, we can't see the error messages. I found the problem by adding
puts stdout.read
and discovering the error message.