18

I installed devise and added config.action_mailer.default_url_options = { :host => 'localhost:3000' } to my development.rb file as suggested. When I run cucumber I get an error:

Missing host to link to! Please provide :host parameter or set default_url_options[:host] (ActionView::Template::Error)

does anyone know what this is related to? not too much info on google about this

lucapette
  • 20,564
  • 6
  • 65
  • 59
jeffci
  • 2,537
  • 6
  • 37
  • 59

2 Answers2

27

Cucumber runs your test environment so you need to add the very same line in test.rb.

apneadiving
  • 114,565
  • 26
  • 219
  • 213
12

For posterity, in case it has nothing to do with mailers but you still get the Missing host error while running capybara, rspec...

If you are using url helpers in your tests and have included somewhere in your rspec config:

config.include Rails.application.routes.url_helpers

Then, you should also add something along this line to the same config:

Rails.application.routes.default_url_options[:host] = "test.host"
Fab V.
  • 1,052
  • 12
  • 17
  • This is true. Ideally, you don't want to hard code the same host and port for the same environment, though. For a DRY solution, check out my answer over here: https://stackoverflow.com/a/48529627/293280 – Joshua Pinter Jan 30 '18 at 20:45