Added mcollective 2.3.1 package
[packages/trusty/mcollective.git] / spec / unit / facts_spec.rb
1 #!/usr/bin/env rspec
2
3 require 'spec_helper'
4
5 module MCollective
6   describe Facts do
7     before do
8       class Facts::Testfacts<Facts::Base; end
9
10       PluginManager.delete("facts_plugin")
11       PluginManager << {:type => "facts_plugin", :class => "MCollective::Facts::Testfacts"}
12     end
13
14     describe "#has_fact?" do
15       it "should correctly report fact presense" do
16         Facts::Testfacts.any_instance.stubs("load_facts_from_source").returns({"foo" => "bar"})
17
18         Facts.has_fact?("foo", "foo").should == false
19         Facts.has_fact?("foo", "bar").should == true
20       end
21     end
22
23     describe "#get_fact" do
24       it "should return the correct fact" do
25         Facts::Testfacts.any_instance.stubs("load_facts_from_source").returns({"foo" => "bar"})
26
27         Facts.get_fact("foo").should == "bar"
28       end
29     end
30
31     describe "#[]" do
32       it "should return the correct fact" do
33         Facts::Testfacts.any_instance.stubs("load_facts_from_source").returns({"foo" => "bar"})
34
35         Facts["foo"].should == "bar"
36       end
37     end
38   end
39 end