Following links in emails with Capybara

Although this just got added to the Capybara README, I thought it worth a quick note here.

When using Rack::Test, beware if attempting to visit absolute URLs. For example, a session might not be shared between visits to posts_path and posts_url. If testing an absolute URL in an Action Mailer email, set default_url_options to match the Rails default of

So, for a Rails app, you’d add this to your config/environments/test.rb file:

config.action_mailer.default_url_options = {:host => ''}

Otherwise, you’ll find yourself losing your user session between requests (steps) in your test.


Published by

Trevor Turk

A chess-playing machine of the late 18th century, promoted as an automaton but later proved a hoax.

One thought on “Following links in emails with Capybara”

Comments are closed.