From b2c9455293796ab1d726314f6e5d2bd021fd648c Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 21 Dec 2009 17:05:47 -0800 Subject: 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 --- lib/puppet/util/settings.rb | 5 ++--- 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 -- cgit