1
require_relative 'gemutilities'
1
require 'rubygems/test_case'
2
2
require 'rubygems/command_manager'
4
class TestGemCommandManager < RubyGemTestCase
4
class TestGemCommandManager < Gem::TestCase
12
12
def test_run_interrupt
13
old_load_path = $:.dup
14
$: << File.expand_path("test/rubygems", @@project_dir)
16
assert_raises MockGemUi::TermError do
18
assert_raises Gem::MockGemUi::TermError do
17
19
@command_manager.run 'interrupt'
19
21
assert_equal '', ui.output
20
22
assert_equal "ERROR: Interrupted\n", ui.error
25
$:.replace old_load_path
26
Gem::CommandManager.reset
24
29
def test_run_crash_command
30
old_load_path = $:.dup
31
$: << File.expand_path("test/rubygems", @@project_dir)
25
33
@command_manager.register_command :crash
27
assert_raises MockGemUi::TermError do
35
assert_raises Gem::MockGemUi::TermError do
28
36
@command_manager.run 'crash'
30
38
assert_equal '', ui.output
31
39
err = ui.error.split("\n").first
32
40
assert_equal "ERROR: Loading command: crash (RuntimeError)", err
43
$:.replace old_load_path
44
@command_manager.unregister_command :crash
36
47
def test_process_args_bad_arg
38
assert_raises(MockGemUi::TermError) {
49
assert_raises Gem::MockGemUi::TermError do
39
50
@command_manager.process_args("--bad-arg")
43
54
assert_match(/invalid option: --bad-arg/i, @ui.error)
56
67
@command_manager.process_args("install")
57
assert_equal false, check_options[:test]
58
68
assert_equal true, check_options[:generate_rdoc]
59
69
assert_equal false, check_options[:force]
60
70
assert_equal :both, check_options[:domain]
67
77
check_options = nil
68
78
@command_manager.process_args(
69
"install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
79
"install --force --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
70
80
assert_equal true, check_options[:generate_rdoc]
71
81
assert_equal true, check_options[:force]
72
82
assert_equal :local, check_options[:domain]
197
207
check_options = nil
198
@command_manager.process_args("update --force --test --rdoc --install-dir .")
208
@command_manager.process_args("update --force --rdoc --install-dir .")
199
209
assert_equal true, check_options[:generate_rdoc]
200
210
assert_equal true, check_options[:force]
201
211
assert_equal Dir.pwd, check_options[:install_dir]