Created
November 18, 2011 18:38
-
-
Save tcaddy/1377322 to your computer and use it in GitHub Desktop.
assert_template in Rails3 mailer test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeMailerTest < ActionMailer::TestCase | |
# include this so that assert_template is defined | |
include ActionController::TemplateAssertions | |
end | |
class SomeMailerTest < ActionMailer::TestCase | |
test "the mailer" do | |
email = SomeMailer.the_mailer.deliver | |
assert_template :partial=>'_the_mailer_partial' | |
end | |
private | |
def validate_request! | |
# this method is added so that assert_template will work | |
# | |
# overrides method defined in ActionDispatch::Assertions::ResponseAssertions | |
# even if you include that module to work around NoMethodError, it won't work b/c @response isn't | |
# an ActionDispatch::Request object | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a hard time writing test coverage for a mailer that used a partial template, b/c assert_template doesn't work out-of-the-box in ActionMailer::TestCase.
I hope this saves other people some time and research.