summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-07 16:48:09 -0800
committerMax Martin <max@puppetlabs.com>2011-03-08 13:16:34 -0800
commit28ce355be0a16caa8e1cc0b6f531d2be070ca6f2 (patch)
treefcca8a27d1af4d596c2384c649159d823f283647 /spec
parent75af5827b68774d0300499fab969239bb8ae6d30 (diff)
downloadpuppet-28ce355be0a16caa8e1cc0b6f531d2be070ca6f2.tar.gz
puppet-28ce355be0a16caa8e1cc0b6f531d2be070ca6f2.tar.xz
puppet-28ce355be0a16caa8e1cc0b6f531d2be070ca6f2.zip
maint: Fix rdoc when documenting manifest files
The structure of the AST has changed from 2.6.x to master, so the code to generate documentation from the AST had to change. Generating documentation for resources other than classes, nodes and defines is still broken, see ticket #6634 Paired-with: Daniel Pittman <daniel@puppetlabs.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/unit/util/rdoc/basic.pp16
-rwxr-xr-xspec/unit/util/rdoc_spec.rb70
2 files changed, 32 insertions, 54 deletions
diff --git a/spec/fixtures/unit/util/rdoc/basic.pp b/spec/fixtures/unit/util/rdoc/basic.pp
new file mode 100644
index 000000000..5616503c1
--- /dev/null
+++ b/spec/fixtures/unit/util/rdoc/basic.pp
@@ -0,0 +1,16 @@
+# im a class
+class foo {
+ file { '/tmp/foo' :
+ ensure => present,
+ }
+}
+
+# im a node
+node gar {
+}
+
+# im a define
+define baz { }
+
+# im a resource
+host { 'cow' : }
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 41d4b9cd0..93c4f9bfa 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -123,63 +123,25 @@ describe Puppet::Util::RDoc do
end
describe "when outputing documentation" do
- before :each do
- @node = stub 'node', :file => "file", :line => 1, :doc => ""
- @class = stub 'class', :file => "file", :line => 4, :doc => ""
- @definition = stub 'definition', :file => "file", :line => 3, :doc => ""
- @ast = stub 'ast', :nodes => { :node => @node }, :hostclasses => { :class => @class }, :definitions => { :definition => @definition }
- end
-
- it "should output doc for ast nodes" do
- @node.expects(:doc)
-
- Puppet::Util::RDoc.output("file", @ast)
- end
-
- it "should output doc for ast classes" do
- @class.expects(:doc)
-
- Puppet::Util::RDoc.output("file", @ast)
- end
-
- it "should output doc for ast definitions" do
- @definition.expects(:doc)
-
- Puppet::Util::RDoc.output("file", @ast)
- end
-
- it "should output doc in order of increasing line number" do
- byline = sequence('byline')
- @node.expects(:doc).in_sequence(byline)
- @definition.expects(:doc).in_sequence(byline)
- @class.expects(:doc).in_sequence(byline)
-
- Puppet::Util::RDoc.output("file", @ast)
- end
-
- it "should not output documentation of ast object of another node" do
- klass = stub 'otherclass', :file => "otherfile", :line => 12, :doc => ""
- @ast.stubs(:hostclasses).returns({ :otherclass => klass })
-
- klass.expects(:doc).never
-
- Puppet::Util::RDoc.output("file", @ast)
+ it "should output doc for ast classes, nodes and definitions in order of increasing line number" do
+ byline = sequence('documentation outputs in line order')
+ Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline)
+ Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline)
+ Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline)
+ # any other output must fail
+ Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')])
end
it "should output resource documentation if needed" do
- Puppet.settings.stubs(:[]).with(:document_all).returns(true)
- [@node,@definition].each do |o|
- o.stubs(:code).returns([])
- end
-
- resource = stub_everything 'resource', :line => 1
- resource.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
- resource.stubs(:is_a?).with(Puppet::Parser::AST::Resource).returns(true)
- @class.stubs(:code).returns([resource])
-
- resource.expects(:doc)
-
- Puppet::Util::RDoc.output("file", @ast)
+ pending "#6634 being fixed"
+ Puppet.settings[:document_all] = true
+ byline = sequence('documentation outputs in line order')
+ Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline)
+ Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline)
+ Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline)
+ Puppet::Util::RDoc.expects(:puts).with("im a resource\n").in_sequence(byline)
+ # any other output must fail
+ Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')])
end
end
end