From 2cc0cac3efce92bf9d0e8636f2889c37ca9f57ab Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 26 Oct 2007 02:21:21 +0000 Subject: Introduce TestCase subclasses for testing rails applications allowing tests to be DRY'd up a bit and to provide a path toward tidying up our monkeypatching of test/unit. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionmailer/test/abstract_unit.rb | 1 + actionmailer/test/test_helper_test.rb | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 649e7982cc..0a73b1b462 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -2,6 +2,7 @@ require 'test/unit' $:.unshift "#{File.dirname(__FILE__)}/../lib" require 'action_mailer' +require 'action_mailer/test_case' # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 08f92865ca..eb17e3e803 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -8,13 +8,38 @@ class TestHelperMailer < ActionMailer::Base end end -class TestHelperTest < Test::Unit::TestCase - def setup - ActionMailer::Base.delivery_method = :test - ActionMailer::Base.perform_deliveries = true - ActionMailer::Base.deliveries = [] +class TestHelperMailerTest < ActionMailer::TestCase + + def test_setup_sets_right_action_mailer_options + assert_equal :test, ActionMailer::Base.delivery_method + assert ActionMailer::Base.perform_deliveries + assert_equal [], ActionMailer::Base.deliveries + end + + def test_setup_creates_the_expected_mailer + assert @expected.is_a?(TMail::Mail) + assert_equal "1.0", @expected.mime_version + assert_equal "text/plain", @expected.content_type + end + + def test_mailer_class_is_correctly_inferred + assert_equal TestHelperMailer, self.class.mailer_class + end + + def test_determine_default_mailer_raises_correct_error + assert_raises(ActionMailer::NonInferrableMailerError) do + self.class.determine_default_mailer("NotAMailerTest") + end end + def test_charset_is_utf_8 + assert_equal "utf-8", charset + end + + def test_encode + assert_equal "=?utf-8?Q?=0aasdf=0a?=", encode("\nasdf\n") + end + def test_assert_emails assert_nothing_raised do assert_emails 1 do -- cgit v1.2.3