Permalink
ActionView::Template::Error in Unit Tests (Rails 3 + Devise)
So I’m resuming development and trying to create coverage for existing code before attempting actual TDD and I get this in my unit tests:
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
These are unit tests! This is madness! Full error:
AdviceTest:
ERROR test: Advice should belong to user. (1.53s)
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
/home/denis/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_dispatch/http/url.rb:25:in `url_for'
The above problem creeps up when you’ve forgot to set mailer settings for Devise in your test environment.
open up config/environments/test.rb and a line to the likes of:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }