summaryrefslogtreecommitdiffstats
path: root/spec/integration
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/integration
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/integration')
-rwxr-xr-xspec/integration/parser/parser.rb21
-rwxr-xr-xspec/integration/util/rdoc/parser.rb4
2 files changed, 23 insertions, 2 deletions
diff --git a/spec/integration/parser/parser.rb b/spec/integration/parser/parser.rb
new file mode 100755
index 000000000..71ae136ed
--- /dev/null
+++ b/spec/integration/parser/parser.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Puppet::Parser::Parser do
+ before :each do
+ @loaded_code = Puppet::Parser::LoadedCode.new
+ @parser = Puppet::Parser::Parser.new :environment => "development", :loaded_code => @loaded_code
+ end
+
+ describe "when parsing comments before statement" do
+ it "should associate the documentation to the statement AST node" do
+ ast = @parser.parse("""
+ # comment
+ class test {}
+ """)
+
+ ast.hostclass("test").doc.should == "comment\n"
+ end
+ end
+end
diff --git a/spec/integration/util/rdoc/parser.rb b/spec/integration/util/rdoc/parser.rb
index df8c62df6..542660998 100755
--- a/spec/integration/util/rdoc/parser.rb
+++ b/spec/integration/util/rdoc/parser.rb
@@ -36,7 +36,7 @@ describe RDoc::Parser do
end
it "should parse to RDoc data structure" do
- @parser.expects(:document_class).with { |n,k,c| n == "::test" and k.is_a?(Puppet::Parser::AST::HostClass) }
+ @parser.expects(:document_class).with { |n,k,c| n == "::test" and k.is_a?(Puppet::Parser::ResourceType) }
@parser.scan
end
-end \ No newline at end of file
+end