Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rack::Handler is deprecated warning when using Rails 7.1 beta and Rack 3 #2705

Closed
mattbrictson opened this issue Sep 13, 2023 · 3 comments · Fixed by #2706
Closed

Rack::Handler is deprecated warning when using Rails 7.1 beta and Rack 3 #2705

mattbrictson opened this issue Sep 13, 2023 · 3 comments · Fixed by #2706

Comments

@mattbrictson
Copy link
Contributor

Meta

  • capybara 3.39.2
  • rack 3.0.8
  • rails 7.1.0.beta1
  • selenium-webdriver 4.12.0
  • ChromeDriver 116.0.5845.96
  • ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]

Using the following system test case config:

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium,
    using: (ENV["SHOW_BROWSER"] ? :chrome : :headless_chrome),
    screen_size: [1400, 1400] do |options|
      options.add_argument("--disable-dev-shm-usage")
      options.add_argument("--no-sandbox")
    end

  setup do
    Capybara.default_max_wait_time = 2
    Capybara.disable_animation = true
    Capybara.server = :puma, {Silent: true}
  end
end

Expected Behavior

Capybara can be used with Rails 7.1 and Rack 3 without warnings.

Actual Behavior

The following warning is printed to stderr:

Rack::Handler is deprecated and replaced by Rackup::Handler

Steps to reproduce

Upgrade a Rails app to Rails 7.1.0.beta1 and run a system test that uses Capybara.

$ bin/rails test:system
Running 4 tests in a single process (parallelization threshold is 50)
Run options: --seed 27755

# Running:

Rack::Handler is deprecated and replaced by Rackup::Handler
....

Finished in 4.122453s, 0.9703 runs/s, 12.1287 assertions/s.
4 runs, 50 assertions, 0 failures, 0 errors, 0 skips

Workaround

The warning goes away if Rack is pinned at 2.x. (Rails 7.1 beta works with Rack 2 and Rack 3.)

gem "rack", "< 3"
mattbrictson added a commit to mattbrictson/capybara that referenced this issue Sep 16, 2023
Before, using capybara on a project with rack 3 would emit the following
warning:

> Rack::Handler is deprecated and replaced by Rackup::Handler

This was because the capybara server registration code for `:puma` was
referencing the deprecated `Rack::Handler::Puma` constant.

Fix by detecting and preferring the `Rackup::Handler::Puma` constant,
if present.

Fixes teamcapybara#2705
@Fjan
Copy link

Fjan commented Oct 8, 2023

Thanks for doing a PR! If you came here by Googling the warning now that Rails 7.1 is released, you could just drop this in app/config/initializers to get rid of the deprecation messages while waiting for this PR to get merged:

if Rails.env.test?
  require 'rackup'
  module Rack
    Handler = ::Rackup::Handler
  end
end

twalpole pushed a commit that referenced this issue Oct 8, 2023
edtect and prefer `Rackup::Handler::Puma` if present.

Fixes #2705
@gap777
Copy link

gap777 commented Nov 13, 2023

This is great! Can we get a release or tag generated to include this?

@adentaofftake
Copy link

So basically all that needs to happen to get this error to go away, is for Capybara to release a new version via a tag? looks like last one was from june

tvararu added a commit to design-history/design-history that referenced this issue Dec 13, 2023
Capybara needs to be bumped:

teamcapybara/capybara#2705

Until then, we can simply link to the latest commit on GitHub.
tvararu added a commit to design-history/design-history that referenced this issue Dec 13, 2023
Capybara needs to be bumped:

teamcapybara/capybara#2705

Until then, we can simply link to the latest commit on GitHub.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants