summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2009-12-21 17:05:47 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitb2c9455293796ab1d726314f6e5d2bd021fd648c (patch)
treefaa03e194b3727233cdf448f3b02097901a4f427
parent8bafc37a532b7bef541186e7bb719f50c0eda600 (diff)
downloadpuppet-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.rb5
-rwxr-xr-xspec/unit/util/settings.rb7
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