eirikir
eirikir

Reputation: 3842

Capybara emails: setting correct port in URLs

I'm using Capybara (2.4.4) with the capybara-email (2.4.0) gem in RSpec (2.14.1) integration tests for my Rails (4.1.6) app. I have a test that ensures the functionality of a link in an email. While Capybara spawns its server on different, random ports each test run, Rails's path helpers in the email views always generate the localhost:3000 domain as specified in my config/environments/test.rb.

How can I specify that the Rails path helpers use the current Capybara test server's host and port for domains?

Upvotes: 1

Views: 634

Answers (1)

jb_314
jb_314

Reputation: 1393

I solved this by specifying the host (but not the port) in test.rb:

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

and including

Capybara.always_include_port = true

in env.rb.

Upvotes: 2

Related Questions