Answer the question
In order to leave comments, you need to log in
How to test mailer call?
Welcome all. The following question arose, it is necessary to test the method call at the controller level: ConfirmOauth.email_confirmation(user).deliver_now
How to implement this in the case of a mailer, where 2 methods are called at once? The following options, of course, do not work:
- expect(ConfirmOauth.email_confirmation(user)).to receive(:deliver_now)
- expect(ConfirmOauth).to receive(:email_confirmation).with(user)
Answer the question
In order to leave comments, you need to log in
let(:confirm_oauth) { double deliver_now: nil }
before do
allow(ConfirmOauth).to receive(:email_confirmation)
.and_return confirm_oauth
end
subject! { do_something_that_calls_mailer }
it do
expect(ConfirmOauth).to have_received(:email_confirmation).with user
expect(confirm_oauth).to have_received :deliver_now
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question