Skip to content

Commit

Permalink
Merge pull request #47239 from jonathanhefner/test_command-thor-help
Browse files Browse the repository at this point in the history
Incorporate Thor help into test command help
  • Loading branch information
jonathanhefner committed Feb 3, 2023
2 parents 834ae02 + 4843a7f commit 960cced
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
9 changes: 9 additions & 0 deletions railties/lib/rails/commands/test/USAGE
@@ -0,0 +1,9 @@
You can run a single test by appending a line number to a filename:

<%= executable %> test/models/user_test.rb:27

You can run multiple files and directories at the same time:

<%= executable %> test/controllers test/integration/login_test.rb

By default test failures and errors are reported inline during a run.
24 changes: 11 additions & 13 deletions railties/lib/rails/commands/test/test_command.rb
Expand Up @@ -8,25 +8,23 @@
module Rails
module Command
class TestCommand < Base # :nodoc:
def self.executable(*args)
args.empty? ? Rails::TestUnitReporter.executable : super
end

no_commands do
def help
say "Usage: #{Rails::TestUnitReporter.executable} [options] [files or directories]"
say ""
say "You can run a single test by appending a line number to a filename:"
say ""
say " #{Rails::TestUnitReporter.executable} test/models/user_test.rb:27"
def help(command_name = nil, *)
super
if command_name == "test"
say ""
say self.class.class_usage
end
say ""
say "You can run multiple files and directories at the same time:"
say ""
say " #{Rails::TestUnitReporter.executable} test/controllers test/integration/login_test.rb"
say ""
say "By default test failures and errors are reported inline during a run."
say ""

Minitest.run(%w(--help))
end
end

desc "test [PATHS...]", "Run tests except system tests"
def perform(*args)
$LOAD_PATH << Rails::Command.root.join("test").to_s

Expand Down

0 comments on commit 960cced

Please sign in to comment.