~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/util/rdoc_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env ruby
2
 
 
3
 
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
 
1
#!/usr/bin/env rspec
 
2
require 'spec_helper'
4
3
 
5
4
require 'puppet/util/rdoc'
6
5
require 'rdoc/rdoc'
7
6
 
8
7
describe Puppet::Util::RDoc do
9
8
 
10
 
  describe "when generating RDoc HTML documentation" do
 
9
  describe "when generating RDoc HTML documentation", :'fails_on_ruby_1.9.2' => true do
11
10
    before :each do
12
11
      @rdoc = stub_everything 'rdoc'
13
12
      RDoc::RDoc.stubs(:new).returns(@rdoc)
123
122
    end
124
123
 
125
124
    describe "when outputing documentation" do
126
 
      before :each do
127
 
        @node = stub 'node', :file => "file", :line => 1, :doc => ""
128
 
        @class = stub 'class', :file => "file", :line => 4, :doc => ""
129
 
        @definition = stub 'definition', :file => "file", :line => 3, :doc => ""
130
 
        @ast = stub 'ast', :nodes => { :node => @node }, :hostclasses => { :class => @class }, :definitions => { :definition => @definition }
131
 
      end
132
 
 
133
 
      it "should output doc for ast nodes" do
134
 
        @node.expects(:doc)
135
 
 
136
 
        Puppet::Util::RDoc.output("file", @ast)
137
 
      end
138
 
 
139
 
      it "should output doc for ast classes" do
140
 
        @class.expects(:doc)
141
 
 
142
 
        Puppet::Util::RDoc.output("file", @ast)
143
 
      end
144
 
 
145
 
      it "should output doc for ast definitions" do
146
 
        @definition.expects(:doc)
147
 
 
148
 
        Puppet::Util::RDoc.output("file", @ast)
149
 
      end
150
 
 
151
 
      it "should output doc in order of increasing line number" do
152
 
        byline = sequence('byline')
153
 
        @node.expects(:doc).in_sequence(byline)
154
 
        @definition.expects(:doc).in_sequence(byline)
155
 
        @class.expects(:doc).in_sequence(byline)
156
 
 
157
 
        Puppet::Util::RDoc.output("file", @ast)
158
 
      end
159
 
 
160
 
      it "should not output documentation of ast object of another node" do
161
 
        klass = stub 'otherclass', :file => "otherfile", :line => 12, :doc => ""
162
 
        @ast.stubs(:hostclasses).returns({ :otherclass => klass })
163
 
 
164
 
        klass.expects(:doc).never
165
 
 
166
 
        Puppet::Util::RDoc.output("file", @ast)
 
125
      it "should output doc for ast classes, nodes and definitions in order of increasing line number" do
 
126
        byline = sequence('documentation outputs in line order')
 
127
        Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline)
 
128
        Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline)
 
129
        Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline)
 
130
        # any other output must fail
 
131
        Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')])
167
132
      end
168
133
 
169
134
      it "should output resource documentation if needed" do
170
 
        Puppet.settings.stubs(:[]).with(:document_all).returns(true)
171
 
        [@node,@definition].each do |o|
172
 
          o.stubs(:code).returns([])
173
 
        end
174
 
 
175
 
        resource = stub_everything 'resource', :line => 1
176
 
        resource.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
177
 
        resource.stubs(:is_a?).with(Puppet::Parser::AST::Resource).returns(true)
178
 
        @class.stubs(:code).returns([resource])
179
 
 
180
 
        resource.expects(:doc)
181
 
 
182
 
        Puppet::Util::RDoc.output("file", @ast)
 
135
        pending "#6634 being fixed"
 
136
        Puppet.settings[:document_all] = true
 
137
        byline = sequence('documentation outputs in line order')
 
138
        Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline)
 
139
        Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline)
 
140
        Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline)
 
141
        Puppet::Util::RDoc.expects(:puts).with("im a resource\n").in_sequence(byline)
 
142
        # any other output must fail
 
143
        Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')])
183
144
      end
184
145
    end
185
146
  end