diff options
| author | Markus Roberts <Markus@reality.com> | 2010-03-24 19:38:43 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 6e04fbaf0a3c0e500d1fb0944fa02fbaaf2eb1b8 (patch) | |
| tree | 79bd19e26d57e216545319d63ba023c8466eaf73 /spec | |
| parent | 33b565a0d76b07f354e2e145e7e03e5a5db69e48 (diff) | |
| download | puppet-6e04fbaf0a3c0e500d1fb0944fa02fbaaf2eb1b8.tar.gz puppet-6e04fbaf0a3c0e500d1fb0944fa02fbaaf2eb1b8.tar.xz puppet-6e04fbaf0a3c0e500d1fb0944fa02fbaaf2eb1b8.zip | |
Fix for #3366 - --tags '' treated as boolean 'true'
This is the patch from Mike Pountney <Mike.Pountney@gmail.com> off
the list with the additional test Luke requested.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/settings.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index 8cc7488d1..1b5440a42 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -79,6 +79,7 @@ describe Puppet::Util::Settings do end it "should support a getopt-specific mechanism for turning booleans off" do + @settings[:bool] = true @settings.handlearg("--no-bool", "") @settings[:bool].should == false end @@ -97,20 +98,33 @@ describe Puppet::Util::Settings do @settings[:bool].should == true end - it "should consider a cli setting with an empty string as an argument to be a boolean" do + it "should consider a cli setting with an empty string as an argument to be a boolean, if the setting itself is a boolean" do # Turn it off first @settings[:bool] = false @settings.handlearg("--bool", "") @settings[:bool].should == true end + it "should consider a cli setting with an empty string as an argument to be an empty argument, if the setting itself is not a boolean" do + @settings[:myval] = "bob" + @settings.handlearg("--myval", "") + @settings[:myval].should == "" + end + it "should consider a cli setting with a boolean as an argument to be a boolean" do # Turn it off first @settings[:bool] = false - @settings.handlearg("--bool", true) + @settings.handlearg("--bool", "true") @settings[:bool].should == true end + it "should not consider a cli setting of a non boolean with a boolean as an argument to be a boolean" do + # Turn it off first + @settings[:myval] = "bob" + @settings.handlearg("--no-myval", "") + @settings[:myval].should == "" + end + it "should clear the cache when setting getopt-specific values" do @settings.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"] @settings[:two].should == "whah yay" |
