return value of deliver_* methods should match ActionMailer
ActionMailer's deliver_ methods return an instance of Mail, which allows for easy unit testing, a la http://edgeguides.rubyonrails.org/testing.html#unit-testing :
email = UserMailer.create_invite('[email protected]',
'[email protected]', Time.now).deliver_now
# Test the body of the sent email contains what we expect it to
assert_equal ['[email protected]'], email.from
Unfortunately sorcery's deliver_ methods (e.g. user.deliver_reset_password_instructions!) return a class object of the user domain object, due to the use of tap inside ActiveRecordAdapter.transaction. It would be very nice if it just returned the return value of the block instead, since the block ends with a call to deliver_now and would just work.
A workaround is to turn your mail unit tests into functional tests and grab the last email off the AM queue, like this:
email = ActionMailer::Base.deliveries.last
+1
Hmm, I agree it could be added like this:
def deliver_password_instructions!
mail = false
transaction do
generate_password
mail = send_mail
end
mail
end
If you can make a PR, I'll be happy to merge it!