Killing fixtures in mailer before they kill me (they usually lead to very brittle tests).
This commit is contained in:
parent
d289e15af9
commit
fb89aba8b4
@ -11,7 +11,7 @@ def copy_view_files
|
||||
|
||||
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
|
||||
|
@ -9,13 +9,6 @@ class MailerGenerator < Base
|
||||
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
|
||||
|
@ -1,3 +0,0 @@
|
||||
<%= class_name %>#<%= @action %>
|
||||
|
||||
Hi, find me in app/views/<%= @path %>
|
@ -3,12 +3,11 @@
|
||||
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 -%>
|
||||
|
@ -28,9 +28,11 @@ def test_check_class_collision
|
||||
|
||||
def test_invokes_default_test_framework
|
||||
run_generator
|
||||
assert_file "test/functional/notifier_test.rb", /class NotifierTest < ActionMailer::TestCase/
|
||||
assert_file "test/fixtures/notifier/foo", /app\/views\/notifier\/foo$/
|
||||
assert_file "test/fixtures/notifier/bar", /app\/views\/notifier\/bar$/
|
||||
assert_file "test/functional/notifier_test.rb" do |test|
|
||||
assert_match /class NotifierTest < ActionMailer::TestCase/, test
|
||||
assert_match /test "foo"/, test
|
||||
assert_match /test "bar"/, test
|
||||
end
|
||||
end
|
||||
|
||||
def test_invokes_default_template_engine
|
||||
|
Loading…
Reference in New Issue
Block a user