summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-11-10 18:19:59 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-11-12 08:02:10 +1100
commit38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df (patch)
tree7df4540de585f8775d219a5e6c459f21ac77fc10 /spec
parent5f7177efeae81c86086d73b3c7869302cfc6a40d (diff)
downloadpuppet-38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df.tar.gz
puppet-38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df.tar.xz
puppet-38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df.zip
Fix #2796 - Fix puppetdoc rdoc selector parsing
This patch fix this bug by adding more to_s methods to ast member so that puppetdoc can just to_s the AST to reconstruct the original puppet code. Of course this is not perfect, but should work most of the time. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/parser/ast/leaf.rb9
-rwxr-xr-xspec/unit/parser/ast/selector.rb9
2 files changed, 17 insertions, 1 deletions
diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb
index e9681503d..fecfba386 100755
--- a/spec/unit/parser/ast/leaf.rb
+++ b/spec/unit/parser/ast/leaf.rb
@@ -72,6 +72,15 @@ describe Puppet::Parser::AST::String do
end
end
+describe Puppet::Parser::AST::Variable do
+ describe "when converting to string" do
+ it "should transform its value to a variable" do
+ value = stub 'value', :is_a? => true, :to_s => "myvar"
+ Puppet::Parser::AST::Variable.new( :value => value ).to_s.should == "\$myvar"
+ end
+ end
+end
+
describe Puppet::Parser::AST::Regex do
before :each do
@scope = stub 'scope'
diff --git a/spec/unit/parser/ast/selector.rb b/spec/unit/parser/ast/selector.rb
index 8b0057784..2ba83ad7b 100755
--- a/spec/unit/parser/ast/selector.rb
+++ b/spec/unit/parser/ast/selector.rb
@@ -151,6 +151,13 @@ describe Puppet::Parser::AST::Selector do
@selector.evaluate(@scope)
end
end
-
+ end
+ describe "when converting to string" do
+ it "should produce a string version of this selector" do
+ values = Puppet::Parser::AST::ASTArray.new :children => [ Puppet::Parser::AST::ResourceParam.new(:param => "type", :value => "value", :add => false) ]
+ param = Puppet::Parser::AST::Variable.new :value => "myvar"
+ selector = Puppet::Parser::AST::Selector.new :param => param, :values => values
+ selector.to_s.should == "$myvar ? { type => value }"
+ end
end
end