diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/cli_spec.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/mixlib/cli_spec.rb b/spec/mixlib/cli_spec.rb index 05c6491..aaa2d3a 100644 --- a/spec/mixlib/cli_spec.rb +++ b/spec/mixlib/cli_spec.rb @@ -156,18 +156,25 @@ describe Mixlib::CLI do @cli.config[:i_am_boolean].should == true end + it "should set the corresponding config value to false when a boolean is prefixed with --no" do + TestCLI.option(:i_am_boolean, :long => "--[no-]bool", :boolean => true) + @cli = TestCLI.new + @cli.parse_options([ '--no-bool' ]) + @cli.config[:i_am_boolean].should == false + end + it "should exit if a config option has :exit set" do TestCLI.option(:i_am_exit, :short => "-x", :boolean => true, :exit => 0) @cli = TestCLI.new lambda { @cli.parse_options(["-x"]) }.should raise_error(SystemExit) end - + it "should exit if a required option is missing" do TestCLI.option(:require_me, :short => "-r", :boolean => true, :required => true) @cli = TestCLI.new lambda { @cli.parse_options([]) }.should raise_error(SystemExit) end - + it "should preserve all of the commandline arguments, ARGV" do TestCLI.option(:config_file, :short => "-c CONFIG") @cli = TestCLI.new |