diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-22 19:54:14 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-22 21:07:37 +0100 |
commit | fb89aba8b45bc5adbd3181ebb2e92ec99e63f821 (patch) | |
tree | 94c7b6011d959bd749e54af493b1667c8fd8c0d8 /railties/lib | |
parent | d289e15af9b2749ba0ab9534b5469287be6ece05 (diff) | |
download | rails-fb89aba8b45bc5adbd3181ebb2e92ec99e63f821.tar.gz rails-fb89aba8b45bc5adbd3181ebb2e92ec99e63f821.tar.bz2 rails-fb89aba8b45bc5adbd3181ebb2e92ec99e63f821.zip |
Killing fixtures in mailer before they kill me (they usually lead to very brittle tests).
Diffstat (limited to 'railties/lib')
4 files changed, 6 insertions, 17 deletions
diff --git a/railties/lib/generators/erb/controller/controller_generator.rb b/railties/lib/generators/erb/controller/controller_generator.rb index d78bcba1b8..b8e8898900 100644 --- a/railties/lib/generators/erb/controller/controller_generator.rb +++ b/railties/lib/generators/erb/controller/controller_generator.rb @@ -11,7 +11,7 @@ module Erb actions.each do |action| @action = action - @path = filename_with_extensions(File.join(base_path, action)) + @path = File.join(base_path, filename_with_extensions(action)) template filename_with_extensions(:view), @path end end 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 -%> |