diff options
author | John Keiser <jkeiser@opscode.com> | 2011-08-25 11:57:27 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2011-08-25 11:57:27 -0700 |
commit | fbcd397f5e9acd4b90fe9f5a9ccf692f172456ca (patch) | |
tree | fd31ca4fe1ce931e1ae0a3e6185ca3242577bdae /spec | |
parent | 8b01a09e9cbf038441a3fbf86fd5632cacbb3faf (diff) | |
download | mixlib-cli-fbcd397f5e9acd4b90fe9f5a9ccf692f172456ca.tar.gz |
CHEF-1563: required options always fail
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/cli_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/mixlib/cli_spec.rb b/spec/mixlib/cli_spec.rb index aaa2d3a..9eed069 100644 --- a/spec/mixlib/cli_spec.rb +++ b/spec/mixlib/cli_spec.rb @@ -175,6 +175,27 @@ describe Mixlib::CLI do lambda { @cli.parse_options([]) }.should raise_error(SystemExit) end + it "should not exit if a required option is specified" do + TestCLI.option(:require_me, :short => "-r", :boolean => true, :required => true) + @cli = TestCLI.new + @cli.parse_options(["-r"]) + @cli.config[:require_me].should == true + end + + it "should not exit if a required boolean option is specified and false" do + TestCLI.option(:require_me, :long => "--[no-]req", :boolean => true, :required => true) + @cli = TestCLI.new + @cli.parse_options(["--no-req"]) + @cli.config[:require_me].should == false + end + + it "should not exit if a required option is specified and empty" do + TestCLI.option(:require_me, :short => "-r VALUE", :required => true) + @cli = TestCLI.new + @cli.parse_options(["-r", ""]) + @cli.config[:require_me].should == "" + end + it "should preserve all of the commandline arguments, ARGV" do TestCLI.option(:config_file, :short => "-c CONFIG") @cli = TestCLI.new |