diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2011-02-11 22:46:15 +0100 |
---|---|---|
committer | Brice Figureau <brice-puppet@daysofwonder.com> | 2011-02-11 22:46:15 +0100 |
commit | b4a171e78c501208798220910352943331ceb9e0 (patch) | |
tree | 460bc89cfc5393613f6a69369b8b22818a469fbe /spec | |
parent | cfa0c32fc5149464af97235a7bb458950d19cc82 (diff) | |
download | puppet-b4a171e78c501208798220910352943331ceb9e0.tar.gz puppet-b4a171e78c501208798220910352943331ceb9e0.tar.xz puppet-b4a171e78c501208798220910352943331ceb9e0.zip |
Fix #5720 - puppetdoc misses some class comments
It appears that the fix for #5252 wasn't complete, and class, nodes and
definition were still using the current lexer line number instead of
the line number of the class/define/node token.
This combined with some missing comments stack pushing/pop on parenthesis
prevented puppetdoc to correctly get the documentation of some class (including
parametrized ones).
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/parser/lexer_spec.rb | 16 | ||||
-rwxr-xr-x | spec/unit/parser/parser_spec.rb | 27 |
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb index 860326973..4ef242cf5 100755 --- a/spec/unit/parser/lexer_spec.rb +++ b/spec/unit/parser/lexer_spec.rb @@ -529,6 +529,22 @@ describe Puppet::Parser::Lexer, "when lexing comments" do @lexer.fullscan end + it "should add a new comment stack level on LPAREN" do + @lexer.string = "(" + + @lexer.expects(:commentpush) + + @lexer.fullscan + end + + it "should pop the current comment on RPAREN" do + @lexer.string = ")" + + @lexer.expects(:commentpop) + + @lexer.fullscan + end + it "should return the current comments on getcomment" do @lexer.string = "# comment" @lexer.fullscan diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb index 07e2d220b..9aab6a716 100755 --- a/spec/unit/parser/parser_spec.rb +++ b/spec/unit/parser/parser_spec.rb @@ -304,6 +304,33 @@ describe Puppet::Parser do it "should return an array of nodes" do @parser.newnode(@nodename).should be_instance_of(Array) end + + it "should initialize the ast context with the correct line number" do + @parser.expects(:ast_context).with { |a,b| b == 123 }.returns({}) + @parser.newnode(@nodename, { :line => 123 }) + end + end + + %w{class define}.each do |entity| + describe "when creating a #{entity}" do + before :each do + @parser.stubs(:ast_context).returns({}) + + @name = stub "#{entity}name", :is_a? => false, :value => "foo" + end + + it "should create and add the correct resource type" do + instance = stub 'instance' + Puppet::Resource::Type.expects(:new).returns(instance) + @parser.known_resource_types.expects(:add).with(instance) + @parser.send("new#{entity}", @name) + end + + it "should initialize the ast context with the correct line number" do + @parser.expects(:ast_context).with { |a,b| b == 123 }.returns({}) + @parser.send("new#{entity}", @name, { :line => 123 }) + end + end end describe "when retrieving a specific node" do |