diff options
author | Shayon Mukherjee <dev@shayon.me> | 2017-08-06 15:53:34 -0700 |
---|---|---|
committer | Shayon Mukherjee <dev@shayon.me> | 2017-08-06 16:58:50 -0700 |
commit | 2d485cfe31247944cecb73152754e365ad2bde8c (patch) | |
tree | 629eafeec9f8cb32586f6d67aed01fdcdfd5d279 /spec | |
parent | 762e8342948147e95e18120a20e641d945e99664 (diff) | |
download | bundler-2d485cfe31247944cecb73152754e365ad2bde8c.tar.gz |
Retry downloading gems consistently across all versions of RubyGems
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/rubygems_integration_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/bundler/rubygems_integration_spec.rb b/spec/bundler/rubygems_integration_spec.rb index 4f8ee38d15..e9c21471d6 100644 --- a/spec/bundler/rubygems_integration_spec.rb +++ b/spec/bundler/rubygems_integration_spec.rb @@ -53,6 +53,31 @@ RSpec.describe Bundler::RubygemsIntegration do end end + describe "#download_gem", :rubygems => ">= 2.0" do + let(:bundler_retry) { double(Bundler::Retry) } + let(:retry) { double("Bundler::Retry") } + let(:uri) { URI.parse("https://foo.bar") } + let(:path) { Gem.path.first } + let(:spec) do + spec = Bundler::RemoteSpecification.new("Foo", Gem::Version.new("2.5.2"), + Gem::Platform::RUBY, nil) + spec.remote = Bundler::Source::Rubygems::Remote.new(uri.to_s) + spec + end + let(:fetcher) { double("gem_remote_fetcher") } + + it "succesfully downloads gem with retries" do + expect(Bundler.rubygems).to receive(:gem_remote_fetcher).and_return(fetcher) + expect(fetcher).to receive(:headers=).with("X-Gemfile-Source" => "https://foo.bar") + expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/"). + and_return(bundler_retry) + expect(bundler_retry).to receive(:attempts).and_yield + expect(fetcher).to receive(:download).with(spec, uri, path) + + Bundler.rubygems.download_gem(spec, uri, path) + end + end + describe "#fetch_all_remote_specs", :rubygems => ">= 2.0" do let(:uri) { URI("https://example.com") } let(:fetcher) { double("gem_remote_fetcher") } |