From d00afeaeed8d23488c319c2fbdbbe8261eebe611 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Mon, 17 May 2010 11:48:30 -0400 Subject: Use assert_equal correctly in actionmailer test (exposing one as broken) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4626 state:resolved] Signed-off-by: José Valim --- actionmailer/test/old_base/mail_service_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index f91e7f893c..f343d32019 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -1048,8 +1048,9 @@ EOF def test_multipart_with_template_path_with_dots mail = FunkyPathMailer.multipart_with_template_path_with_dots(@recipient) assert_equal 2, mail.parts.length - assert "text/plain", mail.parts[1].mime_type - assert "UTF-8", mail.parts[1].charset + assert_equal "text/plain", mail.parts[0].mime_type + assert_equal "text/html", mail.parts[1].mime_type + assert_equal "UTF-8", mail.parts[1].charset end def test_custom_content_type_attributes -- cgit v1.2.3 From b4629528866446aa59f663a1162edbdacee85600 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 18 May 2010 21:47:24 -0400 Subject: Use better assertion methods for testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4645 state:resolved] Signed-off-by: José Valim --- actionmailer/test/base_test.rb | 4 ++-- actionmailer/test/old_base/asset_host_test.rb | 8 ++++---- actionmailer/test/old_base/mail_render_test.rb | 2 +- actionmailer/test/old_base/mail_service_test.rb | 22 +++++++++++----------- actionmailer/test/test_helper_test.rb | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 5506d62d6a..54bf3de6af 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -491,8 +491,8 @@ class BaseTest < ActiveSupport::TestCase # Class level API with method missing test "should respond to action methods" do - assert BaseMailer.respond_to?(:welcome) - assert BaseMailer.respond_to?(:implicit_multipart) + assert_respond_to BaseMailer, :welcome + assert_respond_to BaseMailer, :implicit_multipart assert !BaseMailer.respond_to?(:mail) assert !BaseMailer.respond_to?(:headers) end diff --git a/actionmailer/test/old_base/asset_host_test.rb b/actionmailer/test/old_base/asset_host_test.rb index 0ec0242f55..cc13c8a4d7 100644 --- a/actionmailer/test/old_base/asset_host_test.rb +++ b/actionmailer/test/old_base/asset_host_test.rb @@ -26,7 +26,7 @@ class AssetHostTest < Test::Unit::TestCase def test_asset_host_as_string mail = AssetHostMailer.email_with_asset - assert_equal "\"Somelogo\"", mail.body.to_s.strip + assert_equal %Q{Somelogo}, mail.body.to_s.strip end def test_asset_host_as_one_arguement_proc @@ -38,7 +38,7 @@ class AssetHostTest < Test::Unit::TestCase end } mail = AssetHostMailer.email_with_asset - assert_equal "\"Somelogo\"", mail.body.to_s.strip + assert_equal %Q{Somelogo}, mail.body.to_s.strip end def test_asset_host_as_two_arguement_proc @@ -51,6 +51,6 @@ class AssetHostTest < Test::Unit::TestCase } mail = nil assert_nothing_raised { mail = AssetHostMailer.email_with_asset } - assert_equal "\"Somelogo\"", mail.body.to_s.strip + assert_equal %Q{Somelogo}, mail.body.to_s.strip end -end \ No newline at end of file +end diff --git a/actionmailer/test/old_base/mail_render_test.rb b/actionmailer/test/old_base/mail_render_test.rb index 405d43d7d3..08951833a5 100644 --- a/actionmailer/test/old_base/mail_render_test.rb +++ b/actionmailer/test/old_base/mail_render_test.rb @@ -117,7 +117,7 @@ class RenderHelperTest < Test::Unit::TestCase def test_rxml_template mail = RenderMailer.rxml_template.deliver - assert_equal "\n", mail.body.to_s.strip + assert_equal %(\n), mail.body.to_s.strip end def test_included_subtemplate diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index f343d32019..7054e8052a 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -281,7 +281,7 @@ class TestMailer < ActionMailer::Base from "One: Two " cc "Three: Four " bcc "Five: Six " - body "testing" + body "testing" end def custom_content_type_attributes @@ -289,7 +289,7 @@ class TestMailer < ActionMailer::Base subject "custom content types" from "some.one@somewhere.test" content_type "text/plain; format=flowed" - body "testing" + body "testing" end def return_path @@ -297,7 +297,7 @@ class TestMailer < ActionMailer::Base subject "return path test" from "some.one@somewhere.test" headers["return-path"] = "another@somewhere.test" - body "testing" + body "testing" end def subject_with_i18n(recipient) @@ -417,7 +417,7 @@ class ActionMailerTest < Test::Unit::TestCase end def test_custom_template - expected = new_mail + expected = new_mail expected.to = @recipient expected.subject = "[Signed up] Welcome #{@recipient}" expected.body = "Hello there, \n\nMr. #{@recipient}" @@ -436,7 +436,7 @@ class ActionMailerTest < Test::Unit::TestCase assert ActionView::Template.template_handler_extensions.include?("haml"), "haml extension was not registered" # N.b., custom_templating_extension.text.plain.haml is expected to be in fixtures/test_mailer directory - expected = new_mail + expected = new_mail expected.to = @recipient expected.subject = "[Signed up] Welcome #{@recipient}" expected.body = "Hello there, \n\nMr. #{@recipient}" @@ -453,7 +453,7 @@ class ActionMailerTest < Test::Unit::TestCase end def test_cancelled_account - expected = new_mail + expected = new_mail expected.to = @recipient expected.subject = "[Cancelled] Goodbye #{@recipient}" expected.body = "Goodbye, Mr. #{@recipient}" @@ -477,7 +477,7 @@ class ActionMailerTest < Test::Unit::TestCase end def test_cc_bcc - expected = new_mail + expected = new_mail expected.to = @recipient expected.subject = "testing bcc/cc" expected.body = "Nothing to see here." @@ -602,7 +602,7 @@ class ActionMailerTest < Test::Unit::TestCase def test_unencoded_subject TestMailer.delivery_method = :test - expected = new_mail + expected = new_mail expected.to = @recipient expected.subject = "testing unencoded subject" expected.body = "Nothing to see here." @@ -1151,15 +1151,15 @@ class RespondToTest < Test::Unit::TestCase end def test_should_respond_to_new - assert RespondToMailer.respond_to?(:new) + assert_respond_to RespondToMailer, :new end def test_should_respond_to_create_with_template_suffix - assert RespondToMailer.respond_to?(:create_any_old_template) + assert_respond_to RespondToMailer, :create_any_old_template end def test_should_respond_to_deliver_with_template_suffix - assert RespondToMailer.respond_to?(:deliver_any_old_template) + assert_respond_to RespondToMailer, :deliver_any_old_template end def test_should_not_respond_to_new_with_template_suffix diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 440fb868c8..8ff604c2c7 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -18,7 +18,7 @@ class TestHelperMailerTest < ActionMailer::TestCase end def test_setup_creates_the_expected_mailer - assert @expected.is_a?(Mail::Message) + assert_kind_of Mail::Message, @expected assert_equal "1.0", @expected.mime_version assert_equal "text/plain", @expected.mime_type end @@ -121,7 +121,7 @@ class AnotherTestHelperMailerTest < ActionMailer::TestCase end def test_setup_shouldnt_conflict_with_mailer_setup - assert @expected.is_a?(Mail::Message) + assert_kind_of Mail::Message, @expected assert_equal 'a value', @test_var end end -- cgit v1.2.3