aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_command_manager.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 06:52:18 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 06:52:18 +0000
commit9694bb8cac12969300692dac5a1cf7aa4e3a46cd (patch)
treec3cb423d701f7049ba9382de052e2a937cd1302d /test/rubygems/test_gem_command_manager.rb
parent3f606b7063fc7a8b191556365ad343a314719a8d (diff)
downloadruby-9694bb8cac12969300692dac5a1cf7aa4e3a46cd.tar.gz
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto. * common.mk (prelude): Updated for RubyGems 2.0 source rearrangement. * tool/change_maker.rb: Allow invalid UTF-8 characters in source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_command_manager.rb')
-rw-r--r--test/rubygems/test_gem_command_manager.rb64
1 files changed, 55 insertions, 9 deletions
diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb
index 6cb253d386..e201d73275 100644
--- a/test/rubygems/test_gem_command_manager.rb
+++ b/test/rubygems/test_gem_command_manager.rb
@@ -6,7 +6,47 @@ class TestGemCommandManager < Gem::TestCase
def setup
super
- @command_manager = Gem::CommandManager.instance
+ @command_manager = Gem::CommandManager.new
+ end
+
+ def test_find_command
+ command = @command_manager.find_command 'install'
+
+ assert_kind_of Gem::Commands::InstallCommand, command
+
+ command = @command_manager.find_command 'ins'
+
+ assert_kind_of Gem::Commands::InstallCommand, command
+ end
+
+ def test_find_command_ambiguous
+ e = assert_raises Gem::CommandLineError do
+ @command_manager.find_command 'u'
+ end
+
+ assert_equal 'Ambiguous command u matches [uninstall, unpack, update]',
+ e.message
+ end
+
+ def test_find_command_ambiguous_exact
+ ins_command = Class.new
+ Gem::Commands.send :const_set, :InsCommand, ins_command
+
+ @command_manager.register_command :ins
+
+ command = @command_manager.find_command 'ins'
+
+ assert_kind_of ins_command, command
+ ensure
+ Gem::Commands.send :remove_const, :InsCommand
+ end
+
+ def test_find_command_unknown
+ e = assert_raises Gem::CommandLineError do
+ @command_manager.find_command 'xyz'
+ end
+
+ assert_equal 'Unknown command xyz', e.message
end
def test_run_interrupt
@@ -14,6 +54,8 @@ class TestGemCommandManager < Gem::TestCase
$: << File.expand_path("test/rubygems", @@project_dir)
Gem.load_env_plugins
+ @command_manager.register_command :interrupt
+
use_ui @ui do
assert_raises Gem::MockGemUi::TermError do
@command_manager.run 'interrupt'
@@ -54,6 +96,7 @@ class TestGemCommandManager < Gem::TestCase
assert_match(/invalid option: --bad-arg/i, @ui.error)
end
+ # HACK move to install command test
def test_process_args_install
#capture all install options
use_ui @ui do
@@ -65,7 +108,7 @@ class TestGemCommandManager < Gem::TestCase
#check defaults
@command_manager.process_args("install")
- assert_equal true, check_options[:generate_rdoc]
+ assert_equal %w[ri], check_options[:document].sort
assert_equal false, check_options[:force]
assert_equal :both, check_options[:domain]
assert_equal true, check_options[:wrappers]
@@ -77,7 +120,7 @@ class TestGemCommandManager < Gem::TestCase
check_options = nil
@command_manager.process_args(
"install --force --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
- assert_equal true, check_options[:generate_rdoc]
+ assert_equal %w[rdoc ri], check_options[:document].sort
assert_equal true, check_options[:force]
assert_equal :local, check_options[:domain]
assert_equal false, check_options[:wrappers]
@@ -102,6 +145,7 @@ class TestGemCommandManager < Gem::TestCase
end
end
+ # HACK move to uninstall command test
def test_process_args_uninstall
#capture all uninstall options
check_options = nil
@@ -121,6 +165,7 @@ class TestGemCommandManager < Gem::TestCase
assert_equal Gem::Requirement.new('3.0'), check_options[:version]
end
+ # HACK move to check command test
def test_process_args_check
#capture all check options
check_options = nil
@@ -131,16 +176,15 @@ class TestGemCommandManager < Gem::TestCase
#check defaults
@command_manager.process_args("check")
- assert_equal false, check_options[:verify]
- assert_equal false, check_options[:alien]
+ assert_equal true, check_options[:alien]
#check settings
check_options = nil
- @command_manager.process_args("check --verify foobar --alien")
- assert_equal "foobar", check_options[:verify]
+ @command_manager.process_args("check foobar --alien")
assert_equal true, check_options[:alien]
end
+ # HACK move to build command test
def test_process_args_build
#capture all build options
check_options = nil
@@ -159,6 +203,7 @@ class TestGemCommandManager < Gem::TestCase
assert_equal 'foobar.rb', check_options[:args].first
end
+ # HACK move to query command test
def test_process_args_query
#capture all query options
check_options = nil
@@ -191,6 +236,7 @@ class TestGemCommandManager < Gem::TestCase
assert_equal :both, check_options[:domain]
end
+ # HACK move to update command test
def test_process_args_update
#capture all update options
check_options = nil
@@ -201,12 +247,12 @@ class TestGemCommandManager < Gem::TestCase
#check defaults
@command_manager.process_args("update")
- assert_equal true, check_options[:generate_rdoc]
+ assert_includes check_options[:document], 'rdoc'
#check settings
check_options = nil
@command_manager.process_args("update --force --rdoc --install-dir .")
- assert_equal true, check_options[:generate_rdoc]
+ assert_includes check_options[:document], 'ri'
assert_equal true, check_options[:force]
assert_equal Dir.pwd, check_options[:install_dir]
end