Created
March 25, 2013 16:19
-
-
Save rossta/5238341 to your computer and use it in GitHub Desktop.
Configuring Capybara RackTest driver for Rails in Capybara 2.0.+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Capybara.register_driver :rack_test do |app| | |
| Capybara::RackTest::Driver.new(app, | |
| redirect_limit: 15, | |
| follow_redirects: true, | |
| respect_data_method: true | |
| ) | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_methodto true; this instructs capybara to simulate the request method specified viadata-methodattributes in your link, which normally can be enabled via unobtrusive javascript in real browsers. This setting current defaults tofalseso you may be surprised if you omit this option and suddenly get missing route exceptions in your specs.