summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/facter.rb2
-rwxr-xr-xspec/unit/facter.rb16
2 files changed, 17 insertions, 1 deletions
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" } }