LoginSignup
1
0

More than 1 year has passed since last update.

rspecで ActionView::Template::Error:に遭遇した!

Posted at

メール送信機能を追加した後に、いつも通りプルリクだして自動テストの結果を待ってた
rspec関連は今回いじってなかったのでエラーの通知がslackに飛んできてびっくりし^^;

エラー内容

  2) PostProduct valid if post_id is different
     Failure/Error: <p><%= link_to 'クリックして登録を完了する', controller: 'users/confirmations', action: 'create', confirmation_token: @token %></p>

     ActionView::Template::Error:
       Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

exampleは16作っているのですが、出たエラー全てこれでした。

エラーになっているのは、確認メールの中身なので本当に原因がわからなかった

missing hostって書いてあるくらいだからhostがないのでホストを設定するかonly_pathを設定するかしてくださいみたいな感じかな

解決

hostは設定していたと思っていたのですが、設定していたのはdevelopment環境だけ!!
rspecを実行するtest環境では設定しなかったことに気づき、

config.action_mailer.default_url_options

これをtest.rbに設定しましたところ。。。。。

全てのexampleがパスしました!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0