From e6b0b760cc8bac99765fc43b182505db73e6586b Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 7 Oct 2014 17:40:59 -0500 Subject: [PATCH] fix tests on action_mailer Include appropriate helpers and use `assert_dom_equal` where applicable --- actionmailer/lib/action_mailer/test_case.rb | 2 +- actionmailer/test/asset_host_test.rb | 4 ++-- actionmailer/test/base_test.rb | 6 ++++-- actionmailer/test/url_test.rb | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index b53d2b7fa09..bdda66b32a3 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -16,7 +16,7 @@ module ActionMailer include ActiveSupport::Testing::ConstantLookup include TestHelper - include Rails::Dom::Testing::Assertions::SelectorAssertions + include Rails::Dom::Testing::Assertions included do class_attribute :_mailer_class diff --git a/actionmailer/test/asset_host_test.rb b/actionmailer/test/asset_host_test.rb index dd3b38544fa..10cfdcf6935 100644 --- a/actionmailer/test/asset_host_test.rb +++ b/actionmailer/test/asset_host_test.rb @@ -22,7 +22,7 @@ class AssetHostTest < ActionMailer::TestCase def test_asset_host_as_string mail = AssetHostMailer.email_with_asset - assert_equal %Q{Somelogo}, mail.body.to_s.strip + assert_dom_equal %Q{Somelogo}, mail.body.to_s.strip end def test_asset_host_as_one_argument_proc @@ -32,6 +32,6 @@ class AssetHostTest < ActionMailer::TestCase end } mail = AssetHostMailer.email_with_asset - assert_equal %Q{Somelogo}, mail.body.to_s.strip + assert_dom_equal %Q{Somelogo}, mail.body.to_s.strip end end diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index dcb6959543e..0da22f591f0 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -10,6 +10,8 @@ require 'mailers/proc_mailer' require 'mailers/asset_mailer' class BaseTest < ActiveSupport::TestCase + include Rails::Dom::Testing::Assertions + setup do @original_delivery_method = ActionMailer::Base.delivery_method ActionMailer::Base.delivery_method = :test @@ -536,7 +538,7 @@ class BaseTest < ActiveSupport::TestCase mail = AssetMailer.welcome - assert_equal(%{Dummy}, mail.body.to_s.strip) + assert_dom_equal(%{Dummy}, mail.body.to_s.strip) end test "assets tags should use a Mailer's asset_host settings when available" do @@ -550,7 +552,7 @@ class BaseTest < ActiveSupport::TestCase mail = TempAssetMailer.welcome - assert_equal(%{Dummy}, mail.body.to_s.strip) + assert_dom_equal(%{Dummy}, mail.body.to_s.strip) end test 'the view is not rendered when mail was never called' do diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb index e79b2ca978d..be7532d42f0 100644 --- a/actionmailer/test/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -66,13 +66,13 @@ class ActionMailerUrlTest < ActionMailer::TestCase expected.message_id = '<123@456>' created.message_id = '<123@456>' - assert_equal expected.encoded, created.encoded + assert_dom_equal expected.encoded, created.encoded assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver_now } assert_not_nil ActionMailer::Base.deliveries.first delivered = ActionMailer::Base.deliveries.first delivered.message_id = '<123@456>' - assert_equal expected.encoded, delivered.encoded + assert_dom_equal expected.encoded, delivered.encoded end end