diff options
-rw-r--r-- | lib/puppet/util/feature.rb | 7 | ||||
-rwxr-xr-x | spec/unit/util/feature.rb | 8 |
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 |