|
32 | 32 |
|
33 | 33 | describe "#download_gem" do |
34 | 34 | let(:bundler_retry) { double(Bundler::Retry) } |
35 | | - let(:uri) { Gem::URI.parse("https://foo.bar") } |
36 | 35 | let(:cache_dir) { "#{Gem.path.first}/cache" } |
37 | 36 | let(:spec) do |
38 | 37 | spec = Gem::Specification.new("Foo", Gem::Version.new("2.5.2")) |
|
41 | 40 | end |
42 | 41 | let(:fetcher) { double("gem_remote_fetcher") } |
43 | 42 |
|
44 | | - it "successfully downloads gem with retries" do |
45 | | - expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/"). |
46 | | - and_return(bundler_retry) |
47 | | - expect(bundler_retry).to receive(:attempts).and_yield |
48 | | - expect(fetcher).to receive(:cache_update_path) |
| 43 | + context "when uri is public" do |
| 44 | + let(:uri) { Gem::URI.parse("https://foo.bar") } |
49 | 45 |
|
50 | | - Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher) |
| 46 | + it "successfully downloads gem with retries" do |
| 47 | + expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/"). |
| 48 | + and_return(bundler_retry) |
| 49 | + expect(bundler_retry).to receive(:attempts).and_yield |
| 50 | + expect(fetcher).to receive(:cache_update_path) |
| 51 | + |
| 52 | + Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher) |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + context "when uri contains userinfo part" do |
| 57 | + let(:uri) { Gem::URI.parse("https://#{userinfo}@foo.bar") } |
| 58 | + |
| 59 | + context "with user and password" do |
| 60 | + let(:userinfo) { "user:password" } |
| 61 | + |
| 62 | + it "successfully downloads gem with retries with filtered log" do |
| 63 | + expect(Bundler:: Retry).to receive(:new).with("download gem from https://user:[email protected]/"). |
| 64 | + and_return(bundler_retry) |
| 65 | + expect(bundler_retry).to receive(:attempts).and_yield |
| 66 | + expect(fetcher).to receive(:cache_update_path) |
| 67 | + |
| 68 | + Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher) |
| 69 | + end |
| 70 | + end |
| 71 | + |
| 72 | + context "with token [as user]" do |
| 73 | + let(:userinfo) { "token" } |
| 74 | + |
| 75 | + it "successfully downloads gem with retries with filtered log" do |
| 76 | + expect(Bundler:: Retry).to receive(:new).with("download gem from https://[email protected]/"). |
| 77 | + and_return(bundler_retry) |
| 78 | + expect(bundler_retry).to receive(:attempts).and_yield |
| 79 | + expect(fetcher).to receive(:cache_update_path) |
| 80 | + |
| 81 | + Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher) |
| 82 | + end |
| 83 | + end |
51 | 84 | end |
52 | 85 | end |
53 | 86 |
|
|
0 commit comments