aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Baer <jamesfbaer@gmail.com>2017-02-27 10:17:27 -0500
committerJames Baer <jamesfbaer@gmail.com>2017-02-28 09:09:33 -0500
commit6bee72db6a0261d72280cbc3a5d934245135622a (patch)
tree5ac7b195416b48502e379bd8b58482e9ea5e58e1
parentc971e7f151e76510196bb4ad21c1d7cbb1d0fe96 (diff)
downloadrails-6bee72db6a0261d72280cbc3a5d934245135622a.tar.gz
rails-6bee72db6a0261d72280cbc3a5d934245135622a.tar.bz2
rails-6bee72db6a0261d72280cbc3a5d934245135622a.zip
Improve documentation for Testing Your Mailers [ci skip]
The current Basic Test Case example has the following assertion ``` assert_equal read_fixture('invite').join, email.body.to_s ``` email.body.to_s returns an empty string if both HTML and text templates exist for a given mailer. This commit adds a note to section 11.2.2 explaining this and also suggests using email.text_part.body.to_s and email.html_part.body.to_s as alternatives.
-rw-r--r--guides/source/testing.md4
1 files changed, 4 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 652030a733..4231500729 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -1435,6 +1435,10 @@ variable. We then ensure that it was sent (the first assert), then, in the
second batch of assertions, we ensure that the email does indeed contain what we
expect. The helper `read_fixture` is used to read in the content from this file.
+NOTE: `email.body.to_s` is present when there's only one (HTML or text) part present.
+If the mailer provides both, you can test your fixture against specific parts
+with `email.text_part.body.to_s` or `email.html_part.body.to_s`.
+
Here's the content of the `invite` fixture:
```