New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic Mailer Unit test case doesn't work (Testing 10.2.2) #9325
Comments
There is no section 10 in the ActionMailer docs. Section 6 has something about tests: http://guides.rubyonrails.org/action_mailer_basics.html#mailer-testing It works for me. I have an app here: https://github.com/steveklabnik/issue_9325 Can you help me reproduce this? |
I was referring to section 10 of "A Guide to Testing Rails Applications". The example uses the following testcase: require 'test_helper'
class UserMailerTest < ActionMailer::TestCase
tests UserMailer
test "invite" do
@expected.from = 'me@example.com'
@expected.to = 'friend@example.com'
@expected.subject = "You have been invited by #{@expected.from}"
@expected.body = read_fixture('invite')
@expected.date = Time.now
assert_equal @expected.encoded, UserMailer.create_invite('me@example.com', 'friend@example.com', @expected.date).encoded
end
end This is a different test case from the one @steveklabnik linked to above Currently, I'm using gsub to strip out the Message-ID header from the expected value and the result. |
Ahh, I got confused, I see where you referenced testing.html now. That guide is still a WIP, so it will be a bit off, yes. That said, the edge version has basically the same thing. I'm not sure what the best way is to fix it. |
It's probably better to test against the specific attributes rather than |
Agreed. It seems unnecessary to test the encoded version, especially since On Tue, Feb 19, 2013 at 3:16 PM, Steve Klabnik notifications@github.comwrote:
|
I think so. Honestly, I don't write mailer tests for myself. |
Same as #8128 |
Is there a reason not to write multiple asserts against the generated mail? mail = UserMailer.create_invite('me@example.com', 'friend@example.com')
assert_equal ['friend@example.com'], mail.to
assert_equal ... |
If you implement an ActionMailer using the documentation (action_mailer_basics.html) and implement the basic test case in testing.html section 10.2.2, the test case will fail because the Message-ID headers of the expected and generated message do not match. The documentation doesn't currently explain how to work around this issue.
The text was updated successfully, but these errors were encountered: