diff options
author | Tim Smith <tsmith@chef.io> | 2019-05-13 19:23:59 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2019-05-13 19:23:59 -0700 |
commit | 32ee9105705e3484ddcb2953ed8675c50d5035e7 (patch) | |
tree | 60688e2a7af84fd5e298420d78deb1a26ab57559 /spec | |
parent | 552319d566b65f63fd2f11267ad4d177930a69e0 (diff) | |
download | mixlib-cli-32ee9105705e3484ddcb2953ed8675c50d5035e7.tar.gz |
Add more specs and use or not and
This seems to make more sense
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/cli_spec.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/mixlib/cli_spec.rb b/spec/mixlib/cli_spec.rb index 3adda52..4088f20 100644 --- a/spec/mixlib/cli_spec.rb +++ b/spec/mixlib/cli_spec.rb @@ -224,17 +224,25 @@ describe Mixlib::CLI do expect(@cli.config[:inclusion]).to eql("one") end - it "changes description if :in key is specified" do - TestCLI.option(:inclusion, short: "-i val", in: %w{one two}, description: "desc", required: false) + it "changes description if :in key is specified with a single value" do + TestCLI.option(:inclusion, short: "-i val", in: %w{one}, description: "desc", required: false) @cli = TestCLI.new @cli.parse_options(["-i", "one"]) - expect(@cli.options[:inclusion][:description]).to eql("desc (valid options: 'one' and 'two')") + expect(@cli.options[:inclusion][:description]).to eql("desc (valid options: 'one')") end - it "Raises SystemExit when the provided value is not a member of the :in array" do + it "changes description if :in key is specified with 2 values" 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) + @cli.parse_options(["-i", "one"]) + expect(@cli.options[:inclusion][:description]).to eql("desc (valid options: 'one' or 'two')") + end + + it "changes description if :in key is specified with 3 values" do + TestCLI.option(:inclusion, short: "-i val", in: %w{one two three}, description: "desc", required: false) + @cli = TestCLI.new + @cli.parse_options(["-i", "one"]) + expect(@cli.options[:inclusion][:description]).to eql("desc (valid options: 'one', 'two', or 'three')") end it "doesn't exit if a required option is specified" do |