aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/fetcher/compact_index_spec.rb
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-07-26 22:50:21 +0900
committerHomu <homu@barosl.com>2016-07-26 22:50:21 +0900
commit6904ac6872be56290b12088a6595480de2ae9c53 (patch)
treede6dff8b7eb6cd92487770a5d1de168540f1a722 /spec/bundler/fetcher/compact_index_spec.rb
parent2b649723dc7730b79df7dee3837afcff949f3d3a (diff)
parent8b59481c9fb11d8273ff7606593682dfeabd7dd9 (diff)
downloadbundler-6904ac6872be56290b12088a6595480de2ae9c53.tar.gz
Auto merge of #4811 - NickLaMuro:dots_for_compact_index_logger, r=segiddins
Fix random string printing inconsistencies and formatting Add dot output for CompactIndex fetcher --------------------------------------- The `Bundler::Fetcher::CompactIndex`'s logging was missing the "dot logging" when not in debug mode, which is an assumed behavior based on the code in `lib/bundler/source/rubygems.rb`: ```ruby api_fetchers.each do |f| Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug? idx.use f.specs_with_retry(dependency_names, self) Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over end ``` While this isn't critical for `bundler` function properly by any stretch of the imagination, it provides a small bit of user feedback that requests are still continuing to be processed and `bundler` hasn't stalled. It also maintains logging consistency between the different fetcher models. Add newlines for `Bundler::Retry` --------------------------------- This is very pedantic, but it makes it so that retry warning messages that used to look like this: ``` Fetching gem metadata from https://rubygems.org/....Retrying fetcher due to error (2/4): Error::OMGWatHappened LOL, no idea ..... ``` Now will look like this: ``` Fetching gem metadata from https://rubygems.org/.... Retrying fetcher due to error (2/4): Error::OMGWatHappened LOL, no idea..... ``` I think this reads a bit better and puts context to the "dots" so they now match up with the original attempt and the retries Remove unneeded if statement ---------------------------- Ran across this while failing at writing tests for the above (for longer than I want to admit in public), but basically the `if` statement to determine whether or not to print "name" in the `Bundler.ui.warn` was not needed, as it never could be reached because of a short circuiting return statement prior to the print ```ruby return true unless name ``` Have no idea how to test it anymore than we already are, so instead of embarrassing myself further, I moved on.
Diffstat (limited to 'spec/bundler/fetcher/compact_index_spec.rb')
-rw-r--r--spec/bundler/fetcher/compact_index_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb
index e111d8a3..f6c6ba2e 100644
--- a/spec/bundler/fetcher/compact_index_spec.rb
+++ b/spec/bundler/fetcher/compact_index_spec.rb
@@ -7,6 +7,10 @@ describe Bundler::Fetcher::CompactIndex do
let(:display_uri) { URI("http://sampleuri.com") }
let(:compact_index) { described_class.new(downloader, remote, display_uri) }
+ before do
+ allow(compact_index).to receive(:log_specs) {}
+ end
+
describe "#specs_for_names" do
it "has only one thread open at the end of the run" do
compact_index.specs_for_names(["lskdjf"])
@@ -20,5 +24,31 @@ describe Bundler::Fetcher::CompactIndex do
compact_index.specs_for_names(["lskdjf"])
end
+
+ context "logging" do
+ before { allow(compact_index).to receive(:log_specs).and_call_original }
+
+ context "with debug on" do
+ before do
+ allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(true)
+ end
+
+ it "should log at info level" do
+ expect(Bundler).to receive_message_chain(:ui, :debug).with('Looking up gems ["lskdjf"]')
+ compact_index.specs_for_names(["lskdjf"])
+ end
+ end
+
+ context "with debug off" do
+ before do
+ allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false)
+ end
+
+ it "should log at info level" do
+ expect(Bundler).to receive_message_chain(:ui, :info).with(".", false)
+ compact_index.specs_for_names(["lskdjf"])
+ end
+ end
+ end
end
end