Merge pull request #45085 from shouichi/test-with-leading-dot-slash

Fix rails test command to handle leading dot slash
This commit is contained in:
Jean Boussier 2022-05-13 07:02:44 -04:00 committed by GitHub
commit b5630e232b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,9 @@
* Allow relative paths with leading dot slash to be passed to `rails test`.
Fix `rails test ./test/model/post_test.rb` to run a single test file.
*Shouichi Kamiya* and *oljfte*
* Deprecate `config.enable_dependency_loading`. This flag addressed a limitation of the `classic` autoloader and has no effect nowadays. To fix this deprecation, please just delete the reference. * Deprecate `config.enable_dependency_loading`. This flag addressed a limitation of the `classic` autoloader and has no effect nowadays. To fix this deprecation, please just delete the reference.
*Xavier Noria* *Xavier Noria*

View File

@ -89,7 +89,7 @@ module Rails
end end
def path_argument?(arg) def path_argument?(arg)
%r"^[/\\]?\w+[/\\]".match?(arg) %r"^\.*[/\\]?\w+[/\\]".match?(arg)
end end
def list_tests(argv) def list_tests(argv)

View File

@ -296,6 +296,16 @@ module ApplicationTests
end end
end end
def test_run_relative_path_with_leading_dot_slash
create_test_file :models, "account"
create_test_file :models, "post"
run_test_command("./test/models/account_test.rb").tap do |output|
assert_match "AccountTest", output
assert_match "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips", output
end
end
def test_run_windows_style_path def test_run_windows_style_path
create_test_file :models, "account" create_test_file :models, "account"
create_test_file :controllers, "accounts_controller" create_test_file :controllers, "accounts_controller"