Skip to content

Commit 9f02036

Browse files
committed
Fix system test for scaffolds
Fixes #585
1 parent 7fb4975 commit 9f02036

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/generators/test_unit/scaffold/scaffold_generator.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ module TestUnit # :nodoc:
44
module Generators # :nodoc:
55
class ScaffoldGenerator < Base # :nodoc:
66
def fix_system_test
7-
if turbo_defined? && options[:system_tests]
8-
gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"),
9-
/(click_on.*Destroy this.*)$/,
10-
"accept_confirm { \\1 }"
11-
end
7+
return unless turbo_defined? && options[:system_tests] == "true"
8+
test_file = File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
9+
return unless File.exist?(test_file)
10+
gsub_file test_file, /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }"
1211
end
1312

1413
private

0 commit comments

Comments
 (0)