order_notifier_test.rb 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #---
  2. # Excerpted from "Agile Web Development with Rails",
  3. # published by The Pragmatic Bookshelf.
  4. # Copyrights apply to this code. It may not be used to create training material,
  5. # courses, books, articles, and the like. Contact us if you are in doubt.
  6. # We make no guarantees that this code is fit for any purpose.
  7. # Visit http://www.pragmaticprogrammer.com/titles/rails4 for more book information.
  8. #---
  9. require 'test_helper'
  10. class OrderNotifierTest < ActionMailer::TestCase
  11. test "received" do
  12. mail = OrderNotifier.received(orders(:one))
  13. assert_equal "Pragmatic Store Order Confirmation", mail.subject
  14. assert_equal ["dave@example.org"], mail.to
  15. assert_equal ["depot@example.com"], mail.from
  16. assert_match /1 x Programming Ruby 1.9/, mail.body.encoded
  17. end
  18. test "shipped" do
  19. mail = OrderNotifier.shipped(orders(:one))
  20. assert_equal "Pragmatic Store Order Shipped", mail.subject
  21. assert_equal ["dave@example.org"], mail.to
  22. assert_equal ["depot@example.com"], mail.from
  23. assert_match /<td>1&times;<\/td>\s*<td>Programming Ruby 1.9<\/td>/,
  24. mail.body.encoded
  25. end
  26. end