summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-01-09 15:38:53 -0800
committerdanielsdeleo <dan@opscode.com>2013-01-09 15:38:53 -0800
commitea80b5df1d34c6e6dea73330e7f8c253974aad8d (patch)
treedfb450726c87f75023b34c4e89fb6c2beb85c952 /spec
parenta550028ccacc3885f137fdad06f0b68acd927fb1 (diff)
downloadmixlib-cli-ea80b5df1d34c6e6dea73330e7f8c253974aad8d.tar.gz
[CHEF-3497] optionally store default values separately
This will make it easier for knife to apply config settings in the proper order (default < config file < command line). It's not possible to do without this patch because knife must parse command line options to determine which config file to use.
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/cli_spec.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/mixlib/cli_spec.rb b/spec/mixlib/cli_spec.rb
index 46ec1cf..39740b4 100644
--- a/spec/mixlib/cli_spec.rb
+++ b/spec/mixlib/cli_spec.rb
@@ -57,7 +57,7 @@ describe Mixlib::CLI do
end
end
- describe "instance methods" do
+ context "when configured with default single-config-hash behavior" do
before(:each) do
@cli = TestCLI.new
@@ -214,6 +214,27 @@ describe Mixlib::CLI do
end
end
+ context "when configured to separate default options" do
+ before do
+ TestCLI.use_separate_default_options true
+ TestCLI.option(:defaulter, :short => "-D SOMETHING", :default => "this is the default")
+ @cli = TestCLI.new
+ end
+
+ it "sets default values on the `default` hash" do
+ @cli.parse_options([])
+ @cli.default_config[:defaulter].should == "this is the default"
+ @cli.config[:defaulter].should be_nil
+ end
+
+ it "sets parsed values on the `config` hash" do
+ @cli.parse_options(%w[-D not-default])
+ @cli.default_config[:defaulter].should == "this is the default"
+ @cli.config[:defaulter].should == "not-default"
+ end
+
+ end
+
end