summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-02 07:27:16 +0000
committerJames Turnbull <james@lovedthanlost.net>2009-08-02 17:32:15 +1000
commit97274ad976e3584ae850ad91cc886fae1dcdbbc6 (patch)
tree8d47ec0ffad1284dd7d9916b56323a98cabdc4a8
parent6fb8bf625fcfa12b085101838813ab7bc4635dae (diff)
downloadpuppet-97274ad976e3584ae850ad91cc886fae1dcdbbc6.tar.gz
puppet-97274ad976e3584ae850ad91cc886fae1dcdbbc6.tar.xz
puppet-97274ad976e3584ae850ad91cc886fae1dcdbbc6.zip
Fixing problems my Feature refactor caused
The problems were that I wasn't propagating return values sufficiently, such that false values didn't travel enough, and the 'name' attribute was necessary in the private method but wasn't actually passed in. Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/util/feature.rb7
-rwxr-xr-xspec/unit/util/feature.rb8
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb
index 102bca778..add1b2691 100644
--- a/lib/puppet/util/feature.rb
+++ b/lib/puppet/util/feature.rb
@@ -67,7 +67,7 @@ class Puppet::Util::Feature
ary = [ary] unless ary.is_a?(Array)
ary.each do |lib|
- load_library(lib)
+ return false unless load_library(lib, name)
end
# We loaded all of the required libraries
@@ -76,7 +76,7 @@ class Puppet::Util::Feature
private
- def load_library(lib)
+ def load_library(lib, name)
unless lib.is_a?(String)
raise ArgumentError, "Libraries must be passed as strings not %s" % lib.class
end
@@ -85,7 +85,8 @@ class Puppet::Util::Feature
require lib
rescue Exception
Puppet.debug "Failed to load library '%s' for feature '%s'" % [lib, name]
- result = false
+ return false
end
+ return true
end
end
diff --git a/spec/unit/util/feature.rb b/spec/unit/util/feature.rb
index cf7d06614..576e19bc8 100755
--- a/spec/unit/util/feature.rb
+++ b/spec/unit/util/feature.rb
@@ -60,10 +60,12 @@ describe Puppet::Util::Feature do
@features.should be_myfeature
end
- it "should consider a feature to be absent if any of its libraries are absent" do
+ it "should log and consider a feature to be absent if any of its libraries are absent" do
@features.add(:myfeature, :libs => %w{foo bar})
- @features.expects(:require).with("foo")
- @features.expects(:require).with("bar").raises(LoadError)
+ @features.expects(:require).with("foo").raises(LoadError)
+ @features.stubs(:require).with("bar")
+
+ Puppet.expects(:debug)
@features.should_not be_myfeature
end