Closed p55 closed 8 years ago
@p55 tests are failing.
deliveries
is used only for testing (deliveries - Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test.
), why would you need it here? You should check Mandrill's @response
directly.
@kshnurov specs fixed. Yes - I know that deliveries
are used only for testing and that is my point. For example, you have in your app some code that sends emails
MandrillDm::DeliveryMethod.new.deliver!(mail).each do |response|
# do something with response {:email=>"recipient.email@example.com", :status=>"sent", :reject_reason=>"hard-bounce", :_id=>"abc123abc123abc123abc123abc123"}
end
and you want test your code for example
scenario "user sends email with attachments and some name" do
expect do
visit "/some/path"
fill_in "Subject", with: "Foo"
attach_file "Attachment", "/some/path.txt"
click_button "Go for it"
end.to change {MandrillDm.DeliveryMethod.deliveries.size}.from(0).to(1)
expect(MandrillDm.DeliveryMethod.deliveries.last.subject).to eq("Foo")
expect(MandrillDm.DeliveryMethod.deliveries.last.attachments.size).to eq(1)
end
I don't want to test mandril response (which in fact returns an array of hashes without email details), but messages that have been sent to mandrill api (which are instances of ActionMailer::MessageDelivery
).
@p55 this has absolutely nothing to do with this gem, use default ActionMailer's delivery_method :test
and you'll get the same result.
ActionMailer has nothing to do when sending emails via mandrill api (which is just a POST request on mandrill 'messages/send'
api endpoint)
@p55 so does your tests, they have nothing to do with Mandrill. If you want to test Madrill's response - look into @response
.
MandrillDm.DeliveryMethod.deliveries
returns sent emails. This allows to test if your code properly changed deliveries size (similar toApplicationMailer.deliveries.size
andApplicationMailer.deliveries.last
)