inspired by the episode of railscast (http://railscasts.com/episodes/275-how-i-test) i tried to add some request specs to my app.
using delayed_job for sending my emails, i did not found an easy way to test the sending of emails within my capybara test. i tried:
it "emails user when requesting password reset" do
...(some user action that triggers sending an email)...
Delayed::Worker.new.work_off
ActionMailer::Base.deliveries.last.to.should include(user.email)
end
thanks for any hints or help!
Much easier solution: Just create an initializer in config/initializers, e.g. delayed_job_config.rb
Delayed::Worker.delay_jobs = !Rails.env.test?
In your actual test you do not even need to know that delayed_job is deployed to send the mails, which keeps them clean and simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With