Skip to content

Commit 078a1d6

Browse files
Split up railties/test/command/application_test.rb
Follow-up to rails#47208. Prior to rails#47208, `Rails::Command::ApplicationTest` appears to have been specifically intended to test `Rails::Command::ApplicationCommand`. Therefore, this commit extracts the tests that were added by rails#47208 out from `railties/test/command/application_test.rb` into `railties/test/command/help_integration_test.rb`, and moves `application_test.rb` from `railties/test/command` to `railties/test/commands` (with the rest of the command-specific tests).
1 parent 0f6215a commit 078a1d6

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

railties/test/command/application_test.rb

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require "isolation/abstract_unit"
4+
require "rails/command"
5+
6+
class Rails::Command::HelpIntegrationTest < ActiveSupport::TestCase
7+
setup :build_app
8+
teardown :teardown_app
9+
10+
test "prints helpful error on unrecognized command" do
11+
output = rails "vershen", allow_failure: true
12+
13+
assert_match %(Unrecognized command "vershen"), output
14+
assert_match "Did you mean? version", output
15+
end
16+
17+
test "prints help via `X:help` command when running `X` and `X:X` command is not defined" do
18+
help = rails "dev:help"
19+
output = rails "dev", allow_failure: true
20+
21+
assert_equal help, output
22+
end
23+
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
require "abstract_unit"
4+
require "rails/command"
5+
6+
class Rails::Command::ApplicationTest < ActiveSupport::TestCase
7+
test "rails new without path prints help" do
8+
output = run_application_command "new"
9+
10+
# Doesn't include the default thor error message:
11+
assert_not output.start_with?("No value provided for required arguments")
12+
13+
# Includes contents of ~/railties/lib/rails/generators/rails/app/USAGE:
14+
assert output.include?("The `rails new` command creates a new Rails application with a default
15+
directory structure and configuration at the path you specify.")
16+
end
17+
18+
private
19+
def run_application_command(*args)
20+
capture(:stdout) { Rails::Command.invoke(:application, args) }
21+
end
22+
end

0 commit comments

Comments
 (0)