spec/lib/sendgrid_actionmailer_spec.rb in sendgrid-actionmailer-3.0.1 vs spec/lib/sendgrid_actionmailer_spec.rb in sendgrid-actionmailer-3.0.2

- old
+ new

@@ -57,10 +57,15 @@ it 'sets return_response' do m = DeliveryMethod.new(return_response: true) expect(m.settings[:return_response]).to eq(true) end + + it 'sets perform_deliveries' do + m = DeliveryMethod.new(perform_send_request: false) + expect(m.settings[:perform_send_request]).to eq(false) + end end describe '#deliver!' do let(:client) { TestClient.new } let(:client_parent) { double(client: client) } @@ -752,9 +757,17 @@ mailer.deliver!(mail) expect(client.sent_mail['personalizations'].length).to eq(3) expect(client.sent_mail['personalizations'][0]['bcc']).to eq(personalizations[0]['bcc']) expect(client.sent_mail['personalizations'][1]['bcc']).to eq(personalizations[1]['bcc']) expect(client.sent_mail['personalizations'][2]['bcc']).to eq([{"email"=>"test@sendgrid.com"}]) + end + end + + context 'when perform_send_request false' do + it 'should not send and email and return json body' do + m = DeliveryMethod.new(perform_send_request: false, return_response: true, api_key: 'key') + response = m.deliver!(mail) + expect(response).to respond_to(:to_json) end end end end end