问题描述
所以我的客户已经报告说,很多电子邮件都是错误的,我想编写一些功能测试来查找并确保他们收到电子邮件以及我的规格说明。
我有mandrill_mailer使用mandril api,在发送之前我想看看消息是什么。
So my client has reported that many of the emails are going to the wrong person, and I would like to write some feature tests to find and make sure that they are receiving the email and what it says in my specs.I have mandrill_mailer which uses mandril api, and before it sends out I would like to see what the message is.
例如。创建新的用户帐户 - >创建用户,然后发送欢迎电子邮件。在设计时,它调用RegistrationMailer.new_registration(资源).deliver
,然后向用户发送一封电子邮件:
For example. Create a new user account -> creates the user, and then sends out a welcome email. in devise it calls RegistrationMailer.new_registration(resource).deliverwhich then sends a email to the user:
def new_registration(user)
user = User.find_by_email(user["email"])
mandrill_mail template: 'new-registration',
subject: 'Welcome to ContentBlvd!',
to: { email: user["email"], name: user["full_name"] },
vars: {
'first_name' => user["full_name"],
'unsubscribe' => "#{CONFIG[:protocol]}#{CONFIG[:host]}/unsubscribe?email=#{user.email}"
}
结束
在我的邮件程序中如何测试这个邮件对象?
我尝试过ActionMailer :: Base.deliveries,但它返回nil(因为我使用mandrill邮件...)
所以我试过 - MandrillMailer :: TemplateMailer.message
但没有运气....感谢您的帮帮我。
In my mailer how do I test this mail object?
I tried ActionMailer::Base.deliveries, but it returns nil (Since I'm using mandrill mailer...)So I tried - MandrillMailer::TemplateMailer.messageBut no luck.... Thanks for the help.
推荐答案
此时,MandrillMailer似乎支持选项集。具体来说,现在可以检查 MandrillMailer.deliveries
。
At this point, MandrillMailer appears to support a robust offline testing set of options. In particular, MandrillMailer.deliveries
can now be examined for expectations or debugging purposes.
这篇关于如何用rspec测试mandrill api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!