I'm trying to test a mailer method from my endpoint which looks like this:
ConfirmationMailer.send_email(email).deliver_later
And the corresponding spec looks like this:
let(:confirmation_mailer_stub) { instance_double ConfirmationMailer }
before do
allow(ConfirmationMailer).to receive(:send_email)
end
it 'sends confirmation email' do
call_endpoint
expect(confirmation_mailer_stub).to change { ActionMailer::Base.deliveries.count }.by(1)
end
But I've got an error:
NoMethodError: undefined method `deliver_later' for nil:NilClass
The send_email
method is quite simple:
def send_email(email)
mail(to: email, cc: email)
end
How can I test this method?