aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_local_remote_options.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-10 07:48:56 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-10 07:48:56 +0000
commitfbf59bdbea63efd34ccc144e648467d2f52e7345 (patch)
tree244f0e7ae112cc7dd135e5d1ac24e6c70ba71b4a /test/rubygems/test_gem_local_remote_options.rb
parent7a4aad75356496559460041a6c063bdb736c7236 (diff)
downloadruby-fbf59bdbea63efd34ccc144e648467d2f52e7345.tar.gz
Import RubyGems trunk revision 1493.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_local_remote_options.rb')
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb
new file mode 100644
index 0000000000..d5a6651ade
--- /dev/null
+++ b/test/rubygems/test_gem_local_remote_options.rb
@@ -0,0 +1,84 @@
+require 'test/unit'
+require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
+require 'rubygems/local_remote_options'
+require 'rubygems/command'
+
+class TestGemLocalRemoteOptions < RubyGemTestCase
+
+ def setup
+ super
+
+ @cmd = Gem::Command.new 'dummy', 'dummy'
+ @cmd.extend Gem::LocalRemoteOptions
+ end
+
+ def test_add_local_remote_options
+ @cmd.add_local_remote_options
+
+ args = %w[-l -r -b -B 10 --source http://gems.example.com -p --update-sources]
+ assert @cmd.handles?(args)
+ end
+
+ def test_local_eh
+ assert_equal false, @cmd.local?
+
+ @cmd.options[:domain] = :local
+
+ assert_equal true, @cmd.local?
+
+ @cmd.options[:domain] = :both
+
+ assert_equal true, @cmd.local?
+ end
+
+ def test_remote_eh
+ assert_equal false, @cmd.remote?
+
+ @cmd.options[:domain] = :remote
+
+ assert_equal true, @cmd.remote?
+
+ @cmd.options[:domain] = :both
+
+ assert_equal true, @cmd.remote?
+ end
+
+ def test_source_option
+ @cmd.add_source_option
+
+ s1 = URI.parse 'http://more-gems.example.com'
+ s2 = URI.parse 'http://even-more-gems.example.com'
+
+ @cmd.handle_options %W[--source #{s1} --source #{s2}]
+
+ assert_equal [s1, s2], Gem.sources
+ end
+
+ def test_update_sources_option
+ @cmd.add_update_sources_option
+
+ Gem.configuration.update_sources = false
+
+ @cmd.handle_options %W[--update-sources]
+
+ assert_equal true, Gem.configuration.update_sources
+
+ @cmd.handle_options %W[--no-update-sources]
+
+ assert_equal false, Gem.configuration.update_sources
+ end
+
+ def test_source_option_bad
+ @cmd.add_source_option
+
+ s1 = 'htp://more-gems.example.com'
+
+ assert_raise OptionParser::InvalidArgument do
+ @cmd.handle_options %W[--source #{s1}]
+ end
+
+ assert_equal %w[http://gems.example.com], Gem.sources
+ end
+
+end
+