diff options
author | Colby Swandale <colby@taplaboratories.com> | 2017-12-01 12:26:47 +1100 |
---|---|---|
committer | Colby Swandale <colby@taplaboratories.com> | 2017-12-01 12:26:47 +1100 |
commit | fd585f469fdfca77d4f9637e84ccb6c9a0ed3266 (patch) | |
tree | 388a556f978ac6ebaf71f8e74c3a38461f62cfef | |
parent | 666bb1d7520a2ceabd84a04d769eb572a410ff59 (diff) | |
download | bundler-fd585f469fdfca77d4f9637e84ccb6c9a0ed3266.tar.gz |
add git and gemspec examples to list --paths spec and raise error when --only-names + --paths are used together
-rw-r--r-- | lib/bundler/cli/list.rb | 2 | ||||
-rw-r--r-- | spec/commands/list_spec.rb | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/bundler/cli/list.rb b/lib/bundler/cli/list.rb index 73f69a9eaf..47d512eb70 100644 --- a/lib/bundler/cli/list.rb +++ b/lib/bundler/cli/list.rb @@ -8,6 +8,8 @@ module Bundler def run specs = Bundler.load.specs.reject {|s| s.name == "bundler" }.sort_by(&:name) + + return Bundler.ui.error "The `--name-only` and `--paths` options cannot be used together" if @options["name-only"] && @options["paths"] return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"] return specs.each {|s| Bundler.ui.info s.full_gem_path } if @options["paths"] diff --git a/spec/commands/list_spec.rb b/spec/commands/list_spec.rb index 7fb25963ec..4ebe934ca7 100644 --- a/spec/commands/list_spec.rb +++ b/spec/commands/list_spec.rb @@ -8,6 +8,13 @@ RSpec.describe "bundle list", :bundler => "2" do G end + context "with name-only and paths option" do + it "raises an error" do + bundle "list --name-only --paths" + expect(out).to eq "The `--name-only` and `--paths` options cannot be used together" + end + end + context "with name-only option" do it "prints only the name of the gems in the bundle" do bundle "list --name-only" @@ -17,16 +24,34 @@ RSpec.describe "bundle list", :bundler => "2" do context "with paths option" do before do + build_repo2 do + build_gem "bar" + end + + build_git "git_test", "1.0.0", :path => lib_path("git_test") + + build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s| + s.write("Gemfile", "source :rubygems\ngemspec") + s.add_dependency "bar", "=1.0.0" + end + install_gemfile <<-G - source "file://#{gem_repo1}" + source "file://#{gem_repo2}" gem "rack" gem "rails" + gem "git_test", :git => "#{lib_path("git_test")}" + gemspec :path => "#{tmp.join("gemspec_test")}" G + + bundle! "install" end + it "prints the path of each gem in the bundle" do bundle "list --paths" expect(out).to match(%r{.*\/rails\-2\.3\.2}) - expect(out).to match(%r{.*\/rack\-1\.0\.0}) + expect(out).to match(%r{.*\/rack\-1\.2}) + expect(out).to match(%r{.*\/git_test\-\w}) + expect(out).to match(%r{.*\/gemspec_test}) end end |