diff options
| -rw-r--r-- | lib/puppet/util/settings.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/util/settings.rb | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index f9b9345f3..6a94c0df2 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -134,7 +134,7 @@ class Puppet::Util::Settings end # Handle a command-line argument. - def handlearg(opt, value) + def handlearg(opt, value = nil) @cache.clear value = munge_value(value) if value str = opt.sub(/^--/,'') @@ -146,7 +146,7 @@ class Puppet::Util::Settings end str = str.intern - if value == "" + if value == "" or value.nil? value = bool end diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index 6f92fae46..0bf2dbb19 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -90,6 +90,20 @@ describe Puppet::Util::Settings do @settings[:bool].should == true end + it "should consider a cli setting with no argument to be 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 a boolean" do + # Turn it off first + @settings[:bool] = false + @settings.handlearg("--bool", "") + @settings[:bool].should == true + 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" |
