This document gives examples using RSpec, but the concepts should apply to any testing framework.
In test, we recommend turning off delivery. You can do this in a spec helper, or similar. All calls to #deliver will return true.
require 'apostle'
# Don't attempt to deliver in tests
Apostle.configure do |config|
config.deliver = false
endUnit testing a mailer is quite straight forward. Any action mailer method call using apostle-rails will return an instance of Apostle::Mail, which you can assert the attributes of.
For example, MyMailer.send_welcome(user) would return an instance of Apostle::Mail.
See membership_order_mailer_spec.rb for more information on testing an Apostle::Mail instance.
If you are testing from further out in your code, we recommend simply testing that a mailer has received the object(s) that it expects, and leave the rest to your mailer unit test.
mock_mailer = {}
expect(MyMailer).to receive(:send_welcome).with(user).and_return(mock_mailer)
expect(mock_mailer).to receive(:deliver!)