From 5c19605d6fdbcc854d27904f8c235b43b53267a2 Mon Sep 17 00:00:00 2001 From: Andreas Haller Date: Sun, 21 Mar 2010 04:37:38 +0100 Subject: [PATCH] Fixed test: calling Mail::Body#encoded to get a String (Rails 3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From Rails' CHANGELOG … Mail.body returns a Mail::Body class object, need to call #encoded or #decoded to get the string you want. Signed-off-by: José Valim --- test/mailers/confirmation_instructions_test.rb | 6 +++--- test/mailers/reset_password_instructions_test.rb | 6 +++--- test/mailers/unlock_instructions_test.rb | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/mailers/confirmation_instructions_test.rb b/test/mailers/confirmation_instructions_test.rb index 6367e622..a32d402e 100644 --- a/test/mailers/confirmation_instructions_test.rb +++ b/test/mailers/confirmation_instructions_test.rb @@ -48,13 +48,13 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase end test 'body should have user info' do - assert_match /#{user.email}/, mail.body + assert_match /#{user.email}/, mail.body.encoded end test 'body should have link to confirm the account' do host = ActionMailer::Base.default_url_options[:host] confirmation_url_regexp = %r{} - assert_match confirmation_url_regexp, mail.body + assert_match confirmation_url_regexp, mail.body.encoded end test 'renders a scoped if scoped_views is set to true' do @@ -73,7 +73,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase end test 'mailer sender accepts a proc' do - swap Devise, :mailer_sender => lambda { "another@example.com" } do + swap Devise, :mailer_sender => proc { "another@example.com" } do assert_equal ['another@example.com'], mail.from end end diff --git a/test/mailers/reset_password_instructions_test.rb b/test/mailers/reset_password_instructions_test.rb index 2b83d45a..46ebda16 100644 --- a/test/mailers/reset_password_instructions_test.rb +++ b/test/mailers/reset_password_instructions_test.rb @@ -51,17 +51,17 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase end test 'body should have user info' do - assert_match /#{user.email}/, mail.body + assert_match(/#{user.email}/, mail.body.encoded) end test 'body should have link to confirm the account' do host = ActionMailer::Base.default_url_options[:host] reset_url_regexp = %r{} - assert_match reset_url_regexp, mail.body + assert_match reset_url_regexp, mail.body.encoded end test 'mailer sender accepts a proc' do - swap Devise, :mailer_sender => lambda { "another@example.com" } do + swap Devise, :mailer_sender => proc { "another@example.com" } do assert_equal ['another@example.com'], mail.from end end diff --git a/test/mailers/unlock_instructions_test.rb b/test/mailers/unlock_instructions_test.rb index 1f1d46d7..8799bde3 100644 --- a/test/mailers/unlock_instructions_test.rb +++ b/test/mailers/unlock_instructions_test.rb @@ -51,12 +51,12 @@ class UnlockInstructionsTest < ActionMailer::TestCase end test 'body should have user info' do - assert_match /#{user.email}/, mail.body + assert_match(/#{user.email}/, mail.body.encoded) end test 'body should have link to unlock the account' do host = ActionMailer::Base.default_url_options[:host] unlock_url_regexp = %r{} - assert_match unlock_url_regexp, mail.body + assert_match unlock_url_regexp, mail.body.encoded end end