-
Notifications
You must be signed in to change notification settings - Fork 21.4k
/
help_integration_test.rb
65 lines (49 loc) · 1.69 KB
/
help_integration_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true
require "isolation/abstract_unit"
require "rails/command"
class Rails::Command::HelpIntegrationTest < ActiveSupport::TestCase
setup :build_app
teardown :teardown_app
test "when passing --trace it invokes default" do
assert_match "Invoke default", rails("--trace")
end
test "prints helpful error on unrecognized command" do
output = rails "vershen", allow_failure: true
assert_match %(Unrecognized command "vershen"), output
assert_match "Did you mean? version", output
end
test "loads Rake tasks only once on unrecognized command" do
app_file "lib/tasks/my_task.rake", <<~RUBY
puts "MY_TASK already defined? => \#{!!defined?(MY_TASK)}"
MY_TASK = true
RUBY
output = rails "vershen", allow_failure: true
assert_match "MY_TASK already defined? => false", output
assert_no_match "MY_TASK already defined? => true", output
end
test "prints help via `X:help` command when running `X` and `X:X` command is not defined" do
help = rails "dev:help"
output = rails "dev", allow_failure: true
assert_match help, output
end
test "prints Rake tasks on --tasks / -T option" do
app_file "lib/tasks/my_task.rake", <<~RUBY
Rake.application.clear
desc "my_task"
task :my_task
RUBY
assert_match "my_task", rails("--tasks")
assert_match "my_task", rails("-T")
end
test "excludes application Rake tasks from command list via --help" do
app_file "Rakefile", <<~RUBY, "a"
desc "my_task"
task :my_task_1
RUBY
app_file "lib/tasks/my_task.rake", <<~RUBY
desc "my_task"
task :my_task_2
RUBY
assert_no_match "my_task", rails("--help")
end
end