Update mcollective.init according to OSCI-855
[packages/precise/mcollective.git] / spec / unit / plugins / mcollective / data / agent_data_spec.rb
1 #!/usr/bin/env rspec
2
3 require 'spec_helper'
4
5 require File.dirname(__FILE__) + "/../../../../../plugins/mcollective/data/agent_data.rb"
6
7 module MCollective
8   module Data
9     describe Agent_data do
10       describe "#query_data" do
11         before do
12           @ddl = mock
13           @ddl.stubs(:dataquery_interface).returns({:output => {}})
14           @ddl.stubs(:meta).returns({:timeout => 1})
15           DDL.stubs(:new).returns(@ddl)
16           @plugin = Agent_data.new
17         end
18
19         it "should fail for unknown agents" do
20           expect { @plugin.query_data("rspec") }.to raise_error("No agent called rspec found")
21         end
22
23         it "should retrieve the correct agent and data" do
24           agent = mock
25           agent.stubs(:meta).returns({:license => "license",
26                                         :timeout => "timeout",
27                                         :description => "description",
28                                         :url => "url",
29                                         :version => "version",
30                                         :author => "author"})
31
32           PluginManager.stubs(:[]).with("rspec_agent").returns(agent)
33           PluginManager.expects(:include?).with("rspec_agent").returns(true)
34
35           @plugin.query_data("rspec")
36
37           [:license, :timeout, :description, :url, :version, :author].each do |item|
38             @plugin.result[item].should == item.to_s
39           end
40         end
41       end
42     end
43   end
44 end