Last Updated: February 25, 2016
·
2.321K
· thomasklemm

Set a custom redirect limit for Capybara in Rails

If you see a Capybara::InfiniteRedirectError but want to try to raise the default limit of 5 a little higher to see what happens then, this might help.

# spec/spec_helper.rb
Capybara.register_driver :rack_test do |app|
  Capybara::RackTest::Driver.new(app, :respect_data_method => true, :redirect_limit => 20)
end

The error message (for Google to pick this up).

Capybara::InfiniteRedirectError:
   redirected more than 5 times, check for infinite redirects.

Source: Capybara/Rails.