[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 3a39dd8353b6308cf49522990104cc63e55d7cda
Paul Nasrat
pnasrat at googlemail.com
Fri Jan 29 17:22:37 UTC 2010
The following commit has been merged in the upstream branch:
commit 0e0483ae3f00d408766a850823e3120caedfb9fc
Author: Diego Algorta <diego at oboxodo.com>
Date: Thu Aug 13 14:49:12 2009 -0300
Fix bug where you'd get an 'undefined method' error if trying to access a fact's value when collection has not being yet initialized.
diff --git a/lib/facter.rb b/lib/facter.rb
index d75f275..6e05495 100644
--- a/lib/facter.rb
+++ b/lib/facter.rb
@@ -120,7 +120,7 @@ module Facter
name = name.to_s.sub(/\?$/,'')
end
- if fact = @collection.fact(name)
+ if fact = collection.fact(name)
if question
value = fact.value.downcase
args.each do |arg|
diff --git a/spec/unit/facter.rb b/spec/unit/facter.rb
index bdef726..f248aa7 100755
--- a/spec/unit/facter.rb
+++ b/spec/unit/facter.rb
@@ -82,6 +82,22 @@ describe Facter do
end
end
+ describe "when asked for a fact as an undefined Facter class method" do
+ describe "and the collection is already initialized" do
+ it "should return the fact's value" do
+ Facter.collection
+ Facter.ipaddress.should == Facter['ipaddress'].value
+ end
+ end
+
+ describe "and the collection has been just reset" do
+ it "should return the fact's value" do
+ Facter.reset
+ Facter.ipaddress.should == Facter['ipaddress'].value
+ end
+ end
+ end
+
describe "when passed code as a block" do
it "should execute the provided block" do
Facter.add("block_testing") { setcode { "foo" } }
--
Packaging of Facter for debian
More information about the Pkg-puppet-devel
mailing list