3
require File.dirname(__FILE__) + '/../spec_helper'
5
require 'puppet/reports'
7
describe Puppet::Reports do
8
it "should instance-load report types" do
9
Puppet::Reports.instance_loader(:report).should be_instance_of(Puppet::Util::Autoload)
12
it "should have a method for registering report types" do
13
Puppet::Reports.should respond_to(:register_report)
16
it "should have a method for retrieving report types by name" do
17
Puppet::Reports.should respond_to(:report)
20
it "should provide a method for returning documentation for all reports" do
21
Puppet::Reports.expects(:loaded_instances).with(:report).returns([:one, :two])
22
one = mock 'one', :doc => "onedoc"
23
two = mock 'two', :doc => "twodoc"
24
Puppet::Reports.expects(:report).with(:one).returns(one)
25
Puppet::Reports.expects(:report).with(:two).returns(two)
27
doc = Puppet::Reports.reportdocs
28
doc.include?("onedoc").should be_true
29
doc.include?("twodoc").should be_true
34
describe Puppet::Reports, " when loading report types" do
35
it "should use the instance loader to retrieve report types" do
36
Puppet::Reports.expects(:loaded_instance).with(:report, :myreporttype)
37
Puppet::Reports.report(:myreporttype)
41
describe Puppet::Reports, " when registering report types" do
42
it "should evaluate the supplied block as code for a module" do
43
Puppet::Reports.expects(:genmodule).returns(Module.new)
44
Puppet::Reports.register_report(:testing) { }
47
it "should extend the report type with the Puppet::Util::Docs module" do
48
mod = stub 'module', :define_method => true
50
Puppet::Reports.expects(:genmodule).with { |name, options, block| options[:extend] == Puppet::Util::Docs }.returns(mod)
51
Puppet::Reports.register_report(:testing) { }
54
it "should define a :report_name method in the module that returns the name of the report" do
56
mod.expects(:define_method).with(:report_name)
58
Puppet::Reports.expects(:genmodule).returns(mod)
59
Puppet::Reports.register_report(:testing) { }