From fb89aba8b45bc5adbd3181ebb2e92ec99e63f821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 22 Mar 2010 19:54:14 +0100 Subject: Killing fixtures in mailer before they kill me (they usually lead to very brittle tests). --- railties/lib/generators/test_unit/mailer/mailer_generator.rb | 7 ------- railties/lib/generators/test_unit/mailer/templates/fixture | 3 --- .../generators/test_unit/mailer/templates/functional_test.rb | 11 +++++------ 3 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 railties/lib/generators/test_unit/mailer/templates/fixture (limited to 'railties/lib/generators/test_unit/mailer') diff --git a/railties/lib/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/generators/test_unit/mailer/mailer_generator.rb index a0d73db1b0..1b5985db6d 100644 --- a/railties/lib/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/generators/test_unit/mailer/mailer_generator.rb @@ -9,13 +9,6 @@ module TestUnit def create_test_files template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb") end - - def create_fixtures_files - actions.each do |action| - @action, @path = action, File.join(file_path, action) - template "fixture", File.join("test/fixtures", @path) - end - end end end end diff --git a/railties/lib/generators/test_unit/mailer/templates/fixture b/railties/lib/generators/test_unit/mailer/templates/fixture deleted file mode 100644 index 171648d6fd..0000000000 --- a/railties/lib/generators/test_unit/mailer/templates/fixture +++ /dev/null @@ -1,3 +0,0 @@ -<%= class_name %>#<%= @action %> - -Hi, find me in app/views/<%= @path %> diff --git a/railties/lib/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/generators/test_unit/mailer/templates/functional_test.rb index a2b1f1ed05..0d7c517557 100644 --- a/railties/lib/generators/test_unit/mailer/templates/functional_test.rb +++ b/railties/lib/generators/test_unit/mailer/templates/functional_test.rb @@ -3,12 +3,11 @@ require 'test_helper' class <%= class_name %>Test < ActionMailer::TestCase <% for action in actions -%> test "<%= action %>" do - @expected.subject = <%= action.to_s.humanize.inspect %> - @expected.to = "to@example.org" - @expected.from = "from@example.com" - @expected.body = read_fixture("<%= action %>") - - assert_equal @expected, <%= class_name %>.<%= action %> + mail = <%= class_name %>.<%= action %> + assert_equal <%= action.to_s.humanize.inspect %>, mail.subject + assert_equal ["to@example.org"], mail.to + assert_equal ["from@example.com"], mail.from + assert_match "Hi, find me in app", mail.body.encoded end <% end -%> -- cgit v1.2.3