我正在撰写一份关于铁路3.2的测试,用于我的一个行动邮件——邀请邮件,但似乎发现“接收器”方法。
我的考验如下:
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
我的邀请 邮件收看着:
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>
有什么想法可以做到?