diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-06-01 12:49:40 +0300 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-06-09 12:44:10 +0900 |
commit | 8f37629519ad330032a38ac0e871b2912ed38a1b (patch) | |
tree | bb0529b77583d47993d8b0d608d68896aa3a5298 /spec/bundler/bundler/fetcher | |
parent | 66508992483ae5d77b56a98427c50c772341c0ac (diff) |
Merge bundler master from upstream.
Pick from 8dd59e3ba97eb80a599f8149f31bf40773b69dc0
Diffstat (limited to 'spec/bundler/bundler/fetcher')
-rw-r--r-- | spec/bundler/bundler/fetcher/compact_index_spec.rb | 7 | ||||
-rw-r--r-- | spec/bundler/bundler/fetcher/downloader_spec.rb | 9 | ||||
-rw-r--r-- | spec/bundler/bundler/fetcher/index_spec.rb | 23 |
3 files changed, 34 insertions, 5 deletions
diff --git a/spec/bundler/bundler/fetcher/compact_index_spec.rb b/spec/bundler/bundler/fetcher/compact_index_spec.rb index 5a2d22193a..2f622f6653 100644 --- a/spec/bundler/bundler/fetcher/compact_index_spec.rb +++ b/spec/bundler/bundler/fetcher/compact_index_spec.rb @@ -11,11 +11,14 @@ RSpec.describe Bundler::Fetcher::CompactIndex do end describe "#specs_for_names" do + let(:thread_list) { Thread.list.select {|thread| thread.status == "run" } } + let(:thread_inspection) { thread_list.map {|th| " * #{th}:\n #{th.backtrace_locations.join("\n ")}" }.join("\n") } + it "has only one thread open at the end of the run" do compact_index.specs_for_names(["lskdjf"]) - thread_count = Thread.list.count {|thread| thread.status == "run" } - expect(thread_count).to eq 1 + thread_count = thread_list.count + expect(thread_count).to eq(1), "Expected 1 active thread after `#specs_for_names`, but found #{thread_count}. In particular, found:\n#{thread_inspection}" end it "calls worker#stop during the run" do diff --git a/spec/bundler/bundler/fetcher/downloader_spec.rb b/spec/bundler/bundler/fetcher/downloader_spec.rb index 07b507266b..f985b88982 100644 --- a/spec/bundler/bundler/fetcher/downloader_spec.rb +++ b/spec/bundler/bundler/fetcher/downloader_spec.rb @@ -82,6 +82,15 @@ RSpec.describe Bundler::Fetcher::Downloader do expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError, /Authentication is required for www.uri-to-fetch.com/) end + + context "when the there are credentials provided in the request" do + let(:uri) { URI("http://user:password@www.uri-to-fetch.com") } + + it "should raise a Bundler::Fetcher::BadAuthenticationError that doesn't contain the password" do + expect { subject.fetch(uri, options, counter) }. + to raise_error(Bundler::Fetcher::BadAuthenticationError, /Bad username or password for www.uri-to-fetch.com/) + end + end end context "when the request response is a Net::HTTPNotFound" do diff --git a/spec/bundler/bundler/fetcher/index_spec.rb b/spec/bundler/bundler/fetcher/index_spec.rb index 0cf0ae764e..d5ededae3e 100644 --- a/spec/bundler/bundler/fetcher/index_spec.rb +++ b/spec/bundler/bundler/fetcher/index_spec.rb @@ -35,9 +35,26 @@ RSpec.describe Bundler::Fetcher::Index do context "when a 401 response occurs" do let(:error_message) { "401" } - it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do - expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError, - %r{Authentication is required for http://remote-uri.org}) + before do + allow(remote_uri).to receive(:userinfo).and_return(userinfo) + end + + context "and there was userinfo" do + let(:userinfo) { double(:userinfo) } + + it "should raise a Bundler::Fetcher::BadAuthenticationError" do + expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::BadAuthenticationError, + %r{Bad username or password for http://remote-uri.org}) + end + end + + context "and there was no userinfo" do + let(:userinfo) { nil } + + it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do + expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError, + %r{Authentication is required for http://remote-uri.org}) + end end end |