summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-05-16 09:46:17 -0500
committerLuke Kanies <luke@madstop.com>2008-05-16 09:46:17 -0500
commit03258ebc22526b73f0c7e6550e2aa63712f2b589 (patch)
tree2f56c0cbd2a1ceab2264a3f9e5f6665ac6e816bc
parente02b0b386ed84384daeb2da0879bf215cfcfa2ef (diff)
downloadfacter-03258ebc22526b73f0c7e6550e2aa63712f2b589.tar.gz
facter-03258ebc22526b73f0c7e6550e2aa63712f2b589.tar.xz
facter-03258ebc22526b73f0c7e6550e2aa63712f2b589.zip
Retrieval of fact values now autoloads facts.
I was only autoloading in certain circumstances, but it now autoloads any time you try to load a fact directly.
-rw-r--r--lib/facter/util/collection.rb2
-rwxr-xr-xspec/unit/util/collection.rb7
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/facter/util/collection.rb b/lib/facter/util/collection.rb
index 267424a..edc65c7 100644
--- a/lib/facter/util/collection.rb
+++ b/lib/facter/util/collection.rb
@@ -87,7 +87,7 @@ class Facter::Util::Collection
end
def value(name)
- if fact = @facts[canonize(name)]
+ if fact = fact(name)
fact.value
end
end
diff --git a/spec/unit/util/collection.rb b/spec/unit/util/collection.rb
index 9ea2e9d..81e5d98 100755
--- a/spec/unit/util/collection.rb
+++ b/spec/unit/util/collection.rb
@@ -102,6 +102,11 @@ describe Facter::Util::Collection do
@fact.stubs(:value).returns "result"
end
+ it "should use the 'fact' method to retrieve the fact" do
+ @coll.expects(:fact).with(:yayness).returns @fact
+ @coll.value(:yayness)
+ end
+
it "should return the result of calling :value on the fact" do
@fact.expects(:value).returns "result"
@@ -137,7 +142,7 @@ describe Facter::Util::Collection do
@coll.add(:one)
@coll.add(:two)
- @coll.list.sort.should == [:one, :two].sort
+ @coll.list.sort { |a,b| a.to_s <=> b.to_s }.should == [:one, :two]
end
it "should have a method for returning a hash of fact values" do