お世話になっております。
Railsチュートリアルの11章11.22のrails test:mailers
を実行したら、下記エラーが出力されるため成功しません。
ERROR
1ERROR["test_account_activation", UserMailerTest, 1.1066527760012832] 2 test_account_activation#UserMailerTest (1.11s) 3ArgumentError: ArgumentError: wrong number of arguments (given 1, expected 0) 4 app/mailers/user_mailer.rb:13:in `account_activation' 5 test/mailers/user_mailer_test.rb:9:in `block in <class:UserMailerTest>'
『呼び出し側の引数』と『メソッド側の仮引数』の数がズレているとのことですが、
コード自体はRailsチュートリアルから引用しているものであり、問題ない認識です。
原因がわかる方がいらっしゃいましたら、ご教授お願いします。
#####user_mailer.rb
class UserMailer < ApplicationMailer def account_activation(user) @user = user mail to: user.email, subject: "Account activation" end # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.user_mailer.account_activation.subject # def account_activation @greeting = "Hi" mail to: "to@example.org" end # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.user_mailer.password_reset.subject # def password_reset @greeting = "Hi" mail to: "to@example.org" end end
#####user_mailer_test.rb
require 'test_helper' class UserMailerTest < ActionMailer::TestCase test "account_activation" do user = users(:michael) user.activation_token = User.new_token mail = UserMailer.account_activation(user) assert_equal "Account activation", mail.subject assert_equal [user.email], mail.to assert_equal ["noreply@example.com"], mail.from assert_match user.name, mail.body.encoded assert_match user.activation_token, mail.body.encoded assert_match CGI.escape(user.email), mail.body.encoded end end
###試したこと
rails db:migrate:reset
を実行した後に、rails db:seed
を行いましたが状況は変わりませんでした。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/02/27 12:04