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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# frozen_string_literal: true
require "rubygems"
require_relative "helper"
require "rubygems/commands/help_command"
require "rubygems/package"
require "rubygems/command_manager"
class TestGemCommandsHelpCommand < Gem::TestCase
def setup
super
@cmd = Gem::Commands::HelpCommand.new
end
def test_gem_help_bad
util_gem "bad" do |out, err|
assert_equal("", out)
assert_match "Unknown command bad", err
end
end
def test_gem_help_gem_dependencies
util_gem "gem_dependencies" do |out, err|
assert_match "gem.deps.rb", out
assert_equal "", err
end
end
def test_gem_help_platforms
util_gem "platforms" do |out, err|
assert_match(/x86-freebsd/, out)
assert_equal "", err
end
end
def test_gem_help_build
util_gem "build" do |out, err|
assert_match(/-C PATH *Run as if gem build was started in <PATH>/, out)
assert_equal "", err
end
end
def test_gem_help_commands
mgr = Gem::CommandManager.new
util_gem "commands" do |out, err|
mgr.command_names.each do |cmd|
unless mgr[cmd].deprecated?
assert_match(/\s+#{cmd}\s+\S+/, out)
end
end
if Gem::HAVE_OPENSSL
assert_empty err
refute_match(/No command found for /, out)
end
end
end
def test_gem_help_commands_omits_deprecated_commands
mgr = Gem::CommandManager.new
util_gem "commands" do |out, _err|
deprecated_commands = mgr.command_names.select {|cmd| mgr[cmd].deprecated? }
deprecated_commands.each do |cmd|
refute_match(/\A\s+#{cmd}\s+\S+\z/, out)
end
end
end
def test_gem_no_args_shows_help
util_gem do |out, err|
assert_match(/Usage:/, out)
assert_match(/gem install/, out)
assert_equal "", err
end
end
def util_gem(*args)
@cmd.options[:args] = args
use_ui @ui do
Dir.chdir @tempdir do
@cmd.execute
end
end
yield @ui.output, @ui.error
end
end
|