diff options
author | chrismo <chrismo@clabs.org> | 2016-06-27 22:30:48 -0500 |
---|---|---|
committer | chrismo <chrismo@clabs.org> | 2016-07-08 19:35:57 -0500 |
commit | 9022339885e76c07b015d64258c0a20b0602c141 (patch) | |
tree | 5ac5edd9d97d6d1e306954c7d07fe83f0f49df8d | |
parent | f16f1292a785aac799d46012486d6e715906e43b (diff) | |
download | bundler-9022339885e76c07b015d64258c0a20b0602c141.tar.gz |
Raise message on multiple options
-rw-r--r-- | lib/bundler/cli/update.rb | 5 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 002544ee..1c35659e 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -39,9 +39,10 @@ module Bundler Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby]) end - patch_level = [:major, :minor, :patch].detect {|v| options.keys.include?(v.to_s) } + patch_level = [:major, :minor, :patch].select {|v| options.keys.include?(v.to_s) } + raise ProductionError, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1 Bundler.definition.gem_version_promoter.tap do |gvp| - gvp.level = patch_level || :major + gvp.level = patch_level.first || :major gvp.strict = options[:strict] end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index ce7d2612..90a611dd 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -502,6 +502,14 @@ describe "bundle update conservative" do end end + context "error handling" do + it "raises if too many flags are provided" do + bundle "update --patch --minor" + + expect(out).to eq "Provide only one of the following options: minor, patch" + end + end + context "other commands" do it "Installer could support --dry-run flag for install and update" |