Reputation: 12066
What is the proper way to stub an SMTP error to test your discard_on
or retry_on
for your ActionMailer::DeliveryJob
methods?
Upvotes: 1
Views: 231
Reputation: 12066
I couldn't find any examples, but this is the best I could come up with:
test 'capture an SMTP exception' do
email = MyMailer.with(params).my_message
Mail::Message.any_instance.stubs(:deliver).raises(Net::SMTPSyntaxError)
job = email.deliver_later
job.perform_now
assert_equal 1, job.executions
end
Upvotes: 2