Cucumber + EmailSpec + Rails3: why does it say no emails are sent when it actually works?
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 (ramon@email.com) 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
Wh开发者_StackOverflow中文版at should I do to fix this test?
Thanks!
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.
精彩评论