Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Treat the source as a proper url base. Fixes #304

  • Loading branch information...
commit 1137ed5282b3f7fcc7df23833255840a902cce63 1 parent 5d3d025
@evanphx evanphx authored
View
4 lib/rubygems/commands/fetch_command.rb
@@ -59,11 +59,11 @@ def execute
end
file = "#{spec.full_name}.gem"
- remote_path = source_uri + "gems/#{file}"
+ remote_path = URI.parse(source_uri) + "gems/#{file}"
fetch = Gem::RemoteFetcher.fetcher
- gem = fetch.fetch_path remote_path
+ gem = fetch.fetch_path remote_path.to_s
File.open file, "wb" do |f|
f.write gem
View
25 test/rubygems/test_gem_commands_fetch_command.rb
@@ -73,5 +73,30 @@ def test_execute_version
"#{@a1.full_name} not fetched"
end
+ def test_execute_handles_sources_properly
+ repo = "http://gems.example.com"
+ @uri = URI.parse repo
+
+ Gem.sources.replace [repo]
+
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher @a1, @a2
+
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
+ File.read(@a1.cache_file)
+
+ @cmd.options[:args] = [@a2.name]
+ @cmd.options[:version] = Gem::Requirement.new '1'
+
+ use_ui @ui do
+ Dir.chdir @tempdir do
+ @cmd.execute
+ end
+ end
+
+ assert File.exist?(File.join(@tempdir, @a1.file_name)),
+ "#{@a1.full_name} not fetched"
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.