Rails 3.2 で、ActionMailer の 1 つである InvitationMailer のテストを書いていますが、「受信者」メソッドが見つからないようです。
私のテストは次のようになります。
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>
それが何であるかについて何か考えはありますか?