summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/rdoc/parser.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-12-01 16:41:38 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-12-09 02:13:03 +1100
commit8971d8beae2c409f9052f27c3f80ad3bdfff4de2 (patch)
treec6f7eda0523c31c2b2f3a02b3761bf43ef716ebf /spec/unit/util/rdoc/parser.rb
parent39d4a935d47f1d42241ce492c48818dc5b533c29 (diff)
downloadpuppet-8971d8beae2c409f9052f27c3f80ad3bdfff4de2.tar.gz
puppet-8971d8beae2c409f9052f27c3f80ad3bdfff4de2.tar.xz
puppet-8971d8beae2c409f9052f27c3f80ad3bdfff4de2.zip
Fixing #2596 - Node, Class, Definition are not AST
This commit extracts these three classes into a single ResourceType class in the Parser heirarchy, now completely independent of the AST heirarchy. Most of the other changes are just changing the interface to the new class, which is greatly simplified over the previous classes. This opens up the possibility of drastically simplifying a lot of this other code, too -- in particular, replacing the reference to the parser with a reference to the (soon to be renamed) LoadedCode class. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/util/rdoc/parser.rb')
-rwxr-xr-xspec/unit/util/rdoc/parser.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/spec/unit/util/rdoc/parser.rb b/spec/unit/util/rdoc/parser.rb
index 593e6acc8..19c91bb9a 100755
--- a/spec/unit/util/rdoc/parser.rb
+++ b/spec/unit/util/rdoc/parser.rb
@@ -137,9 +137,9 @@ describe RDoc::Parser do
describe "when parsing AST elements" do
before :each do
- @klass = stub_everything 'klass', :file => "module/manifests/init.pp", :classname => "myclass"
- @definition = stub_everything 'definition', :file => "module/manifests/init.pp"
- @node = stub_everything 'node', :file => "module/manifests/init.pp"
+ @klass = stub_everything 'klass', :file => "module/manifests/init.pp", :name => "myclass", :type => :hostclass
+ @definition = stub_everything 'definition', :file => "module/manifests/init.pp", :type => :definition, :name => "mydef"
+ @node = stub_everything 'node', :file => "module/manifests/init.pp", :type => :node, :name => "mynode"
@loadedcode = Puppet::Parser::LoadedCode.new
@parser.ast = @loadedcode
@@ -148,7 +148,7 @@ describe RDoc::Parser do
end
it "should document classes in the parsed file" do
- @loadedcode.add_hostclass("myclass", @klass)
+ @loadedcode.add_hostclass(@klass)
@parser.expects(:document_class).with("myclass", @klass, @container)
@@ -157,7 +157,7 @@ describe RDoc::Parser do
it "should not document class parsed in an other file" do
@klass.stubs(:file).returns("/not/same/path/file.pp")
- @loadedcode.add_hostclass("myclass", @klass)
+ @loadedcode.add_hostclass(@klass)
@parser.expects(:document_class).with("myclass", @klass, @container).never
@@ -165,10 +165,11 @@ describe RDoc::Parser do
end
it "should document vardefs for the main class" do
- @loadedcode.add_hostclass(:main, @klass)
+ @klass.stubs(:name).returns :main
+ @loadedcode.add_hostclass(@klass)
code = stub 'code', :is_a? => false
- @klass.stubs(:classname).returns("")
+ @klass.stubs(:name).returns("")
@klass.stubs(:code).returns(code)
@parser.expects(:scan_for_vardef).with(@container, code)
@@ -177,7 +178,7 @@ describe RDoc::Parser do
end
it "should document definitions in the parsed file" do
- @loadedcode.add_definition("mydef", @definition)
+ @loadedcode.add_definition(@definition)
@parser.expects(:document_define).with("mydef", @definition, @container)
@@ -186,7 +187,7 @@ describe RDoc::Parser do
it "should not document definitions parsed in an other file" do
@definition.stubs(:file).returns("/not/same/path/file.pp")
- @loadedcode.add_definition("mydef", @definition)
+ @loadedcode.add_definition(@definition)
@parser.expects(:document_define).with("mydef", @definition, @container).never
@@ -194,7 +195,7 @@ describe RDoc::Parser do
end
it "should document nodes in the parsed file" do
- @loadedcode.add_node("mynode", @node)
+ @loadedcode.add_node(@node)
@parser.expects(:document_node).with("mynode", @node, @container)
@@ -203,7 +204,7 @@ describe RDoc::Parser do
it "should not document node parsed in an other file" do
@node.stubs(:file).returns("/not/same/path/file.pp")
- @loadedcode.add_node("mynode", @node)
+ @loadedcode.add_node(@node)
@parser.expects(:document_node).with("mynode", @node, @container).never