黄瓜 +电子邮件规范 + Rails3:为什么它实际上工作时说没有发送电子邮件?
我正在使用 EmailSpec 来测试 Cucumber 的电子邮件。我的测试失败,并表示没有发送电子邮件,但是我找不到我的代码有任何问题,因此我在生产中进行了尝试,并且发送了电子邮件。
这是失败的步骤:
# ...
And I should see "You have requested for a condition report, and will be emailed one as soon as we are able to process your request." # features/step_definitions/web_steps.rb:107
And I should receive an email # features/step_definitions/email_steps.rb:51
expected: 1,
got: 0 (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/email_steps.rb:52:in `/^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/'
features/request_for_condition_reports.feature:18:in `And I should receive an email'
When I open the email # features/step_definitions/email_steps.rb:72
Then I should see "Ramon ([email protected]) wants a condition report for" in the email body
这是发送电子邮件的类:
class ReportRequest < ActiveRecord::Base
...
private
def notify_admin
Mailer.condition_report_request_to_admin(self).deliver
end
end
我应该做什么来修复此测试?
谢谢!
I'm using EmailSpec to test emails with Cucumber. My tests fail and says no email is being sent, but I couldn't find anything wrong with my code, so I tried it in production and emails are sent.
Here's the failing step:
# ...
And I should see "You have requested for a condition report, and will be emailed one as soon as we are able to process your request." # features/step_definitions/web_steps.rb:107
And I should receive an email # features/step_definitions/email_steps.rb:51
expected: 1,
got: 0 (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/email_steps.rb:52:in `/^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/'
features/request_for_condition_reports.feature:18:in `And I should receive an email'
When I open the email # features/step_definitions/email_steps.rb:72
Then I should see "Ramon ([email protected]) wants a condition report for" in the email body
And here's the class that sends the email:
class ReportRequest < ActiveRecord::Base
...
private
def notify_admin
Mailer.condition_report_request_to_admin(self).deliver
end
end
What should I do to fix this test?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来我不是唯一一个遇到这个问题的人!您应该将 email_steps.rb 中设置的默认电子邮件更改为您希望用来接收电子邮件的电子邮件。
It seems I wasn't the only one that had this problem! You're supposed to change the default email set in email_steps.rb to the email that you expect to receive emails with.