我正在尝试从我的端点测试一个邮递员方法,如下所示:
Confirmationmailer.send_email(email).deliver_later
相应的规格如下:
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
但是我有一个错误:
NoMethodError: nil:NilClass的未定义方法`deliver_later'
send_email
方法非常简单:
def send_email(email)
mail(to: email,cc: email)
end
如何测试此方法?