X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Funit%2Ffacts_spec.rb;fp=spec%2Funit%2Ffacts_spec.rb;h=270524260ed591922751f7dfd877ec09daa486bb;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/spec/unit/facts_spec.rb b/spec/unit/facts_spec.rb new file mode 100755 index 0000000..2705242 --- /dev/null +++ b/spec/unit/facts_spec.rb @@ -0,0 +1,39 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +module MCollective + describe Facts do + before do + class Facts::Testfacts "facts_plugin", :class => "MCollective::Facts::Testfacts"} + end + + describe "#has_fact?" do + it "should correctly report fact presense" do + Facts::Testfacts.any_instance.stubs("load_facts_from_source").returns({"foo" => "bar"}) + + Facts.has_fact?("foo", "foo").should == false + Facts.has_fact?("foo", "bar").should == true + end + end + + describe "#get_fact" do + it "should return the correct fact" do + Facts::Testfacts.any_instance.stubs("load_facts_from_source").returns({"foo" => "bar"}) + + Facts.get_fact("foo").should == "bar" + end + end + + describe "#[]" do + it "should return the correct fact" do + Facts::Testfacts.any_instance.stubs("load_facts_from_source").returns({"foo" => "bar"}) + + Facts["foo"].should == "bar" + end + end + end +end