Test case exposing an issue when using Capybara/Rack::Test with SSL
Ruby JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
db
doc
features
lib/tasks
log
public
script
test
vendor/plugins/ssl_requirement
README
Rakefile
rerun.txt

README

The test case can be run with script/cucumber features/ssl.feature
A before_filter in ApplicationController prints out details about every request, so you can observe Capybara (or Rack::Test) losing the HTTPS protocol once it followed the redirect from ssl_requirement.

The issue (http://github.com/jnicklas/capybara/issues#issue/85) is this:

Capybara does not play nice with sites that have some actions protected by SSL, some not. A popular way to implement this in Rails is using the ssl_requirement plugin by DHH, which redirects a requests from HTTP to HTTPS if the requested action requires SSL and vice versa.

Capybara follows the redirect, but seems to forget the changed protocol for the next request. The only workaround right now is to use URLs in lieu of paths everywhere (links, form actions).