Remove redundant suffixes on generated system tests.

This commit is contained in:
Gannon McGibbon 2018-12-11 18:09:16 -05:00
parent 5742344024
commit b93fc47c72
3 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,7 @@
* Remove redundant suffixes on generated system tests.
*Gannon McGibbon*
* Add an `abort_on_failure` boolean option to the generator method that shell
out (`generate`, `rake`, `rails_command`) to abort the generator if the
command fails.

View File

@ -14,6 +14,11 @@ module TestUnit # :nodoc:
template "system_test.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
end
private
def file_name
@_file_name ||= super.sub(/_test\z/i, "")
end
end
end
end

View File

@ -16,4 +16,18 @@ class SystemTestGeneratorTest < Rails::Generators::TestCase
run_generator %w(admin/user)
assert_file "test/system/admin/users_test.rb", /class Admin::UsersTest < ApplicationSystemTestCase/
end
def test_test_name_is_pluralized
run_generator %w(user)
assert_no_file "test/system/user_test.rb"
assert_file "test/system/users_test.rb"
end
def test_test_suffix_is_not_duplicated
run_generator %w(users_test)
assert_no_file "test/system/users_test_test.rb"
assert_file "test/system/users_test.rb"
end
end