summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_sources_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_commands_sources_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb40
1 files changed, 39 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index b63fbce81f..3a0899245b 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -247,7 +247,7 @@ source http://gems.example.com/ already present in the cache
end
def test_execute_add_http_rubygems_org
- http_rubygems_org = 'http://rubygems.org'
+ http_rubygems_org = 'http://rubygems.org/'
spec_fetcher do |fetcher|
fetcher.spec 'a', 1
@@ -284,6 +284,44 @@ source http://gems.example.com/ already present in the cache
assert_empty @ui.error
end
+ def test_execute_add_https_rubygems_org
+ https_rubygems_org = 'https://rubygems.org/'
+
+ spec_fetcher do |fetcher|
+ fetcher.spec 'a', 1
+ end
+
+ specs = Gem::Specification.map do |spec|
+ [spec.name, spec.version, spec.original_platform]
+ end
+
+ specs_dump_gz = StringIO.new
+ Zlib::GzipWriter.wrap specs_dump_gz do |io|
+ Marshal.dump specs, io
+ end
+
+ @fetcher.data["#{https_rubygems_org}/specs.#{@marshal_version}.gz"] =
+ specs_dump_gz.string
+
+ @cmd.handle_options %W[--add #{https_rubygems_org}]
+
+ ui = Gem::MockGemUi.new "n"
+
+ use_ui ui do
+ assert_raises Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+ end
+
+ assert_equal [@gem_repo], Gem.sources
+
+ expected = <<-EXPECTED
+ EXPECTED
+
+ assert_equal expected, @ui.output
+ assert_empty @ui.error
+ end
+
def test_execute_add_bad_uri
@cmd.handle_options %w[--add beta-gems.example.com]