Search code examples
ruby-on-railsseleniumcucumberemail-spec

Email delivery testing with email_spec breaks on Rails 3.0.11 -> 3.1.3


I'm in process of migrating a rails 3.0.11 app to 3.1.3. And somehow, this breaks email_spec testing for amount of emails received when using cucumber + selenium setup.

config.action_mailer.delivery_method = :test, also have tried it with :cache and :file delivery methods. No matter what, ActionMailer::Base.deliveries is empty, even tho according to logs, the emails get sent. And dropping back down to to rails 3.0.11 makes everything work again.

Edit: For specific versions, here is my Gemfile.lock (note that spork is not used for cucumber features).

Clues, anyone?


Solution

  • Try setting:

    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries.clear
    

    in your features/support/env.rb or more simply it's a bug somewhere, here we can see people with similar problems: https://github.com/bmabey/email-spec/issues?sort=created&direction=desc&state=open&page=1

    Keep an eye out to not send real emails for some reason (bugs, etc.)

    delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, :test, and :file. Or you may provide a custom delivery method object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to implement for a custom delivery agent.

    perform_deliveries - Determines whether emails are actually sent from Action Mailer when you call .deliver on an mail message or on an Action Mailer method. This is on by default but can be turned off to aid in functional testing.

    deliveries - Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful for unit and functional testing.