summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-14 17:23:35 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-14 18:52:21 +0100
commitc0c5c08066051e1d74f2d863770d481d10915b2d (patch)
tree71b422303949e4ec6199eee2770fd68f944a219a
parente4f3bbc97ef4da58e626f67207575576f217617d (diff)
downloadbundler-c0c5c08066051e1d74f2d863770d481d10915b2d.tar.gz
Port regexp feature from `bundle show`
-rw-r--r--lib/bundler/cli/info.rb2
-rw-r--r--spec/commands/info_spec.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
index 61d4001c6f..4bc66932d6 100644
--- a/lib/bundler/cli/info.rb
+++ b/lib/bundler/cli/info.rb
@@ -25,7 +25,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)
+ spec || default_gem_spec(gem_name) || Bundler::CLI::Common.select_spec(gem_name, :regex_match)
end
def default_gem_spec(gem_name)
diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb
index 7d9e8d3094..ebed80f922 100644
--- a/spec/commands/info_spec.rb
+++ b/spec/commands/info_spec.rb
@@ -116,6 +116,19 @@ RSpec.describe "bundle info" do
end
end
+ context "with a valid regexp for gem name" do
+ it "presents alternatives" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ bundle "info rac"
+ expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
+ end
+ end
+
context "with an invalid regexp for gem name" do
it "does not find the gem" do
install_gemfile <<-G