summaryrefslogtreecommitdiff
path: root/spec/mixlib
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-05-13 19:16:50 -0700
committerTim Smith <tsmith@chef.io>2019-05-13 19:16:50 -0700
commit552319d566b65f63fd2f11267ad4d177930a69e0 (patch)
treeb4f15ce2c7c8c77e74f2f05f62632eac7cfcea64 /spec/mixlib
parent5601bd1811b6182b93681bd30c286e69fc52597f (diff)
downloadmixlib-cli-552319d566b65f63fd2f11267ad4d177930a69e0.tar.gz
Print out human readable lists of allowed CLI options
Give a nice friendly sentence and not an array. This uses the code we nuked from chef/chef that did the same. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/mixlib')
-rw-r--r--spec/mixlib/cli_spec.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/mixlib/cli_spec.rb b/spec/mixlib/cli_spec.rb
index c9bc5e4..3adda52 100644
--- a/spec/mixlib/cli_spec.rb
+++ b/spec/mixlib/cli_spec.rb
@@ -228,7 +228,13 @@ describe Mixlib::CLI do
TestCLI.option(:inclusion, short: "-i val", in: %w{one two}, description: "desc", required: false)
@cli = TestCLI.new
@cli.parse_options(["-i", "one"])
- expect(@cli.options[:inclusion][:description]).to eql("desc (valid options are: ['one', 'two'])")
+ expect(@cli.options[:inclusion][:description]).to eql("desc (valid options: 'one' and 'two')")
+ end
+
+ it "Raises SystemExit when the provided value is not a member of the :in array" do
+ TestCLI.option(:inclusion, short: "-i val", in: %w{one two}, description: "desc", required: false)
+ @cli = TestCLI.new
+ expect(lambda { @cli.parse_options(["-i", "three"]) }).to raise_error(SystemExit)
end
it "doesn't exit if a required option is specified" do