我正在为我的一个 ActionMailer - InvitationMailer 在 Rails 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
我的 InvitationMailer 看起来像这样:
class InvitationMailer < ActionMailer::Base
default from: "webmaster@myapp.com"
def invitation_email(user)
recipients user.email
from "invitations@myapp.com"
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>
知道它可能是什么吗?