summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-11-08 13:41:08 +0100
committergit <svn-admin@ruby-lang.org>2024-11-25 14:57:03 +0000
commiteb87147bda31b200b0b88a8c39689739381a4b62 (patch)
tree0831ff4ee15fe3e17c49a2da4afe8a34f62ca3a8
parent77990f67518382e0eb25af30d7d120957ba70285 (diff)
[rubygems/rubygems] Improve index fetcher specs
https://github.com/rubygems/rubygems/commit/09e0971ab8
-rw-r--r--spec/bundler/bundler/fetcher/index_spec.rb24
1 files changed, 8 insertions, 16 deletions
diff --git a/spec/bundler/bundler/fetcher/index_spec.rb b/spec/bundler/bundler/fetcher/index_spec.rb
index dff9ccc3cc..a6a18efd98 100644
--- a/spec/bundler/bundler/fetcher/index_spec.rb
+++ b/spec/bundler/bundler/fetcher/index_spec.rb
@@ -4,7 +4,9 @@ require "rubygems/remote_fetcher"
RSpec.describe Bundler::Fetcher::Index do
let(:downloader) { nil }
- let(:remote) { nil }
+ let(:remote) { double(:remote, uri: remote_uri) }
+ let(:remote_uri) { Gem::URI("http://#{userinfo}remote-uri.org") }
+ let(:userinfo) { "" }
let(:display_uri) { "http://sample_uri.com" }
let(:rubygems) { double(:rubygems) }
let(:gem_names) { %w[foo bar] }
@@ -20,10 +22,8 @@ RSpec.describe Bundler::Fetcher::Index do
end
context "error handling" do
- let(:remote_uri) { Gem::URI("http://remote-uri.org") }
before do
allow(rubygems).to receive(:fetch_all_remote_specs) { raise Gem::RemoteFetcher::FetchError.new(error_message, display_uri) }
- allow(subject).to receive(:remote_uri).and_return(remote_uri)
end
context "when certificate verify failed" do
@@ -38,25 +38,17 @@ RSpec.describe Bundler::Fetcher::Index do
context "when a 401 response occurs" do
let(:error_message) { "401" }
- before do
- allow(remote_uri).to receive(:userinfo).and_return(userinfo)
+ 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
context "and there was userinfo" do
- let(:userinfo) { double(:userinfo) }
+ let(:userinfo) { "user:pass@" }
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})
+ %r{Bad username or password for http://user@remote-uri.org})
end
end
end