Cucumber + EmailSpec + Rails3:为什么它说实际上没有发送电子邮件?

时间:2010-11-22 10:40:55

标签: ruby-on-rails cucumber

我正在使用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 (ramon@email.com) 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

我该怎么做才能解决这个问题呢?

谢谢!

1 个答案:

答案 0 :(得分:1)

似乎我wasn't the only one遇到了这个问题!您应该将email_steps.rb中的默认电子邮件集更改为您希望收到电子邮件的电子邮件。