Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are emails not getting in the ActionMailer::Base.deliveries table?

Currently in my development environment I am not seeing anything in the ActionMailer::Base.deliveries table after mail is used. Is there a setting I am missing?

config/environments/development.rb:
config.action_mailer.delivery_method = :test.

app/mailers/notifier.rb

def send_email(user)
  mail(:to => user.email, :subject => "Welcome to our website!")
end

These are the tests I'm running:

When /^I signup$/ do
  visit signup_path
  @user = FactoryGirl.build(:user)
  fill_in "user_email", :with => @user.email
  fill_in "user_password", :with => @user.password
  click_button "Join now"
end

Then /^I should receive a confirmation email$/ do
  email = ActionMailer::Base.deliveries.last
  email.subject.should == "Welcome to our website!"
end

Right now I get the following error for the I should receive a confirmation email step: undefined method subject for nil:NilClass (NoMethodError)

Thanks!

like image 975
Goalie Avatar asked Dec 16 '22 00:12

Goalie


1 Answers

Another possibility might be that in config/environments/test.rb you have

config.action_mailer.delivery_method = :test

but you have set

config.action_mailer.perform_deliveries = false

so changing to

config.action_mailer.perform_deliveries = true

made it work again in my case.

like image 137
Dominik Steiner Avatar answered Jan 14 '23 15:01

Dominik Steiner