summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-04-18 10:26:38 +0900
committerHomu <homu@barosl.com>2016-04-18 10:26:38 +0900
commit9d2676ed2b9a58ff9251ff55210747c5a07ab201 (patch)
treecf08939a635f5e1274434e1bb75611b308762fad
parentba23e13a8c4420c91d2d866e3bcaed18cbb03d1b (diff)
parente110c4562cfb54d1f88d2a6d1c4d66b1fe9d49e5 (diff)
downloadbundler-9d2676ed2b9a58ff9251ff55210747c5a07ab201.tar.gz
Auto merge of #4419 - RochesterinNYC:specify-full-index-usage-in-error-message, r=segiddins
Suggest usage of `--full-index` flag in case of Dependency API failure - Closes #4384 \cc @indirect Could use some review on this as to if the appropriate error message has been changed.
-rw-r--r--lib/bundler/fetcher/dependency.rb6
-rw-r--r--spec/bundler/fetcher/dependency_spec.rb36
2 files changed, 26 insertions, 16 deletions
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index 8b41fe9999..0e67375de8 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -33,10 +33,14 @@ module Bundler
returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
- rescue HTTPError, MarshalError, GemspecError
+ rescue MarshalError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
+ rescue HTTPError, GemspecError
+ Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
+ Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
+ nil
end
def dependency_specs(gem_names)
diff --git a/spec/bundler/fetcher/dependency_spec.rb b/spec/bundler/fetcher/dependency_spec.rb
index fd0d5ed9d3..b11bcdcd79 100644
--- a/spec/bundler/fetcher/dependency_spec.rb
+++ b/spec/bundler/fetcher/dependency_spec.rb
@@ -79,6 +79,9 @@ describe Bundler::Fetcher::Dependency do
allow(bundler_retry).to receive(:attempts) {|&block| block.call }
allow(subject).to receive(:log_specs) {}
allow(subject).to receive(:remote_uri).and_return(remote_uri)
+ allow(Bundler).to receive_message_chain(:ui, :debug?)
+ allow(Bundler).to receive_message_chain(:ui, :info)
+ allow(Bundler).to receive_message_chain(:ui, :debug)
end
context "when there are given gem names that are not in the full dependency list" do
@@ -139,21 +142,10 @@ describe Bundler::Fetcher::Dependency do
end
shared_examples_for "the error is properly handled" do
- before do
- allow(Bundler).to receive_message_chain(:ui, :debug?)
- allow(Bundler).to receive_message_chain(:ui, :info)
- allow(Bundler).to receive_message_chain(:ui, :debug)
- end
-
it "should return nil" do
expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to be_nil
end
- it "should log the inability to fetch from API at debug level" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
-
context "debug logging is not on" do
before { allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false) }
@@ -164,22 +156,36 @@ describe Bundler::Fetcher::Dependency do
end
end
+ shared_examples_for "the error suggests retrying with the full index" do
+ it "should log the inability to fetch from API at debug level" do
+ expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`")
+ subject.specs(gem_names, full_dependency_list, last_spec_list)
+ end
+ end
+
context "when an HTTPError occurs" do
before { allow(subject).to receive(:dependency_specs) { raise Bundler::HTTPError.new } }
it_behaves_like "the error is properly handled"
+ it_behaves_like "the error suggests retrying with the full index"
end
- context "when a MarshalError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::MarshalError.new } }
+ context "when a GemspecError occurs" do
+ before { allow(subject).to receive(:dependency_specs) { raise Bundler::GemspecError.new } }
it_behaves_like "the error is properly handled"
+ it_behaves_like "the error suggests retrying with the full index"
end
- context "when a GemspecError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::GemspecError.new } }
+ context "when a MarshalError occurs" do
+ before { allow(subject).to receive(:dependency_specs) { raise Bundler::MarshalError.new } }
it_behaves_like "the error is properly handled"
+
+ it "should log the inability to fetch from API and mention retrying" do
+ expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
+ subject.specs(gem_names, full_dependency_list, last_spec_list)
+ end
end
end