diff options
author | Luke Kanies <luke@reductivelabs.com> | 2009-12-21 17:05:47 -0800 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | b2c9455293796ab1d726314f6e5d2bd021fd648c (patch) | |
tree | faa03e194b3727233cdf448f3b02097901a4f427 | |
parent | 8bafc37a532b7bef541186e7bb719f50c0eda600 (diff) | |
download | puppet-b2c9455293796ab1d726314f6e5d2bd021fd648c.tar.gz puppet-b2c9455293796ab1d726314f6e5d2bd021fd648c.tar.xz puppet-b2c9455293796ab1d726314f6e5d2bd021fd648c.zip |
Fixing #3148 Settings#without_noop when run with no noop setting
Some tests didn't define this setting which caused this method
to fail.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
-rw-r--r-- | lib/puppet/util/settings.rb | 5 | ||||
-rwxr-xr-x | spec/unit/util/settings.rb | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index e6e13339b..3a28c46a0 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -163,11 +163,10 @@ class Puppet::Util::Settings end def without_noop - old_noop = value(:noop,:cli) - set_value(:noop, false, :cli) + old_noop = value(:noop,:cli) and set_value(:noop, false, :cli) if valid?(:noop) yield ensure - set_value(:noop, old_noop, :cli) + set_value(:noop, old_noop, :cli) if valid?(:noop) end def include?(name) diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index 4855df4b8..8cc7488d1 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -1034,5 +1034,12 @@ describe Puppet::Util::Settings do @settings.without_noop { raise } rescue nil @settings.value(:noop, :cli).should be_true end + + it "should work even if no 'noop' setting is available" do + settings = Puppet::Util::Settings.new + stuff = nil + settings.without_noop { stuff = "yay" } + stuff.should == "yay" + end end end |