Though I don't recommend excessive redirects, sometimes you need more than 5 in your Capybara specs; this is the default redirect limit for Capybara. When you exceed this limit, you get a dreaded
In Capybara 2.0+, this limit is configurable:
Capybara.register\_driver :rack\_test do |app| Capybara::RackTest::Driver.new app, \\ redirect_limit: 15, follow_redirects: true, respect_data_method: true end
Register a new instance of the rack test driver with options, as shown above. If you're on Rails, it may be necessary for you to set
capybara/rails is to set this option. So... you may be surprised if you omit this option and suddenly get missing route exceptions in your specs.
The best long term solution for you and your users is to figure out how to reduce or eliminate unnecessary redirects. Playing with the redirect limit in your test environment may be a good way to identify potential problem areas of your app.