Skip to content

Instantly share code, notes, and snippets.

@rossta
Created March 25, 2013 16:19
Show Gist options
  • Select an option

  • Save rossta/5238341 to your computer and use it in GitHub Desktop.

Select an option

Save rossta/5238341 to your computer and use it in GitHub Desktop.
Configuring Capybara RackTest driver for Rails in Capybara 2.0.+
Capybara.register_driver :rack_test do |app|
Capybara::RackTest::Driver.new(app,
redirect_limit: 15,
follow_redirects: true,
respect_data_method: true
)
end
@rossta
Copy link
Author

rossta commented Mar 25, 2013

First of all, I don't recommended excessive redirects.

Sometimes, you need more than 5 in your tests, which is the default limit for Capybara. This limit is configurable and can be done by registering 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 respect_data_method to true; this instructs capybara to simulate the request method specified via data-method attributes in your link, which normally can be enabled via unobtrusive javascript in real browsers. This setting current defaults to false so you may be surprised if you omit this option and suddenly get missing route exceptions in your specs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment