diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-03-31 11:27:57 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-03-31 11:27:57 +0200 |
commit | 08aa7ad902f20f2508d8fd88abc15b5cb4d09dd7 (patch) | |
tree | cd468c0899b6e62647fc27a0058be0de8e999c68 | |
parent | 61a56579cb6232fc02967ea2264b623ee64f16c6 (diff) | |
download | bundler-no_default_gems_on_bundle_info.tar.gz |
Don't consider default gems on `bundle info`no_default_gems_on_bundle_info
Unless explicitly included in the bundle.
-rw-r--r-- | lib/bundler/cli/info.rb | 8 | ||||
-rw-r--r-- | spec/commands/info_spec.rb | 28 |
2 files changed, 25 insertions, 11 deletions
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb index 4733675e8c..674ac37d5a 100644 --- a/lib/bundler/cli/info.rb +++ b/lib/bundler/cli/info.rb @@ -26,13 +26,7 @@ module Bundler def spec_for_gem(gem_name) spec = Bundler.definition.specs.find {|s| s.name == gem_name } - spec || default_gem_spec(gem_name) || Bundler::CLI::Common.select_spec(gem_name, :regex_match) - end - - def default_gem_spec(gem_name) - return unless Gem::Specification.respond_to?(:find_all_by_name) - gem_spec = Gem::Specification.find_all_by_name(gem_name).last - return gem_spec if gem_spec && gem_spec.respond_to?(:default_gem?) && gem_spec.default_gem? + spec || Bundler::CLI::Common.select_spec(gem_name, :regex_match) end def spec_not_found(gem_name) diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb index 3c511cfc61..264ba9f9a0 100644 --- a/spec/commands/info_spec.rb +++ b/spec/commands/info_spec.rb @@ -41,10 +41,30 @@ RSpec.describe "bundle info" do end context "given a default gem shippped in ruby", :ruby_repo do - it "prints information about the default gem" do - bundle "info rdoc" - expect(out).to include("* rdoc") - expect(out).to include("Default Gem: yes") + context "when included in the bundle" do + before do + install_gemfile <<-G + gem "rdoc" + G + end + + it "prints information about the default gem" do + bundle "info rdoc" + expect(out).to include("* rdoc") + expect(out).to include("Default Gem: yes") + end + end + + context "when not included in the bundle" do + before do + install_gemfile <<-G + G + end + + it "does not print information about the default gem" do + bundle "info rdoc" + expect(err).to include("Could not find gem 'rdoc'") + end end end |