~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to spec/unit/reports.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mfrom: (1.1.8 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080726154345-c03m49twzxewdwjn
Tags: 0.24.5-2
* Fix puppetlast to work with 0.24.5
* Adjust logcheck to match against new log messages in 0.24.5
* Update standards version to 3.8.0 (no changes)
* Update changelog to reduce length of line to make lintian happy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../spec_helper'
 
4
 
 
5
require 'puppet/reports'
 
6
 
 
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)
 
10
    end
 
11
 
 
12
    it "should have a method for registering report types" do
 
13
        Puppet::Reports.should respond_to(:register_report)
 
14
    end
 
15
 
 
16
    it "should have a method for retrieving report types by name" do
 
17
        Puppet::Reports.should respond_to(:report)
 
18
    end
 
19
 
 
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)
 
26
 
 
27
        doc = Puppet::Reports.reportdocs
 
28
        doc.include?("onedoc").should be_true
 
29
        doc.include?("twodoc").should be_true
 
30
    end
 
31
end
 
32
 
 
33
 
 
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)
 
38
    end
 
39
end
 
40
 
 
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) { }
 
45
    end
 
46
 
 
47
    it "should extend the report type with the Puppet::Util::Docs module" do
 
48
        mod = stub 'module', :define_method => true
 
49
 
 
50
        Puppet::Reports.expects(:genmodule).with { |name, options, block| options[:extend] == Puppet::Util::Docs }.returns(mod)
 
51
        Puppet::Reports.register_report(:testing) { }
 
52
    end
 
53
 
 
54
    it "should define a :report_name method in the module that returns the name of the report" do
 
55
        mod = mock 'module'
 
56
        mod.expects(:define_method).with(:report_name)
 
57
 
 
58
        Puppet::Reports.expects(:genmodule).returns(mod)
 
59
        Puppet::Reports.register_report(:testing) { }
 
60
    end
 
61
end