我正在爲我的一個ActionMailers - InvitationMailer寫一個測試,但是,它似乎找不到「收件人」方法。ActionMailer:未定義的方法`收件人'爲
我的測試如下所示:
describe "Invitation" do
it "should send invitation email to user" do
user = Factory :user
email = InvitationMailer.invitation_email(user).deliver
# Send the email, then test that it got queued
assert !ActionMailer::Base.deliveries.empty?
# Test the body of the sent email contains what we expect it to
assert_equal [user.email], email.to
assert_equal "You have been Invited!", email.subject
end
我InvitationMailer看起來是這樣的:
class InvitationMailer < ActionMailer::Base
default from: "[email protected]"
def invitation_email(user)
recipients user.email
from "[email protected]"
subject "You have been Invited!"
body :user => user
end
end
我然而,收到以下錯誤信息:
Failure/Error: email = InvitationEmail.invitation_email(user).deliver
NoMethodError:
undefined method `recipients' for #<InvitationMailer:0x007fca0b41f7f8>
任何想法它可能是?
什麼版本的Rails?猜測2.X? – x1a4
不,其軌道3.2.2 – Karan