summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/ast
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2010-07-19 12:32:46 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-19 19:56:09 -0700
commit06fc40c5d755a41c8ece84a3d437572a64b4c899 (patch)
tree25bd26521604d2881fbb5c6429310031fb86ea56 /spec/unit/parser/ast
parent1288f8c4051105d6cfbf4f532d5e5e926613e9df (diff)
downloadpuppet-06fc40c5d755a41c8ece84a3d437572a64b4c899.tar.gz
puppet-06fc40c5d755a41c8ece84a3d437572a64b4c899.tar.xz
puppet-06fc40c5d755a41c8ece84a3d437572a64b4c899.zip
[#4269] Undef variables interpolate to empty string
This fixes double-quoted strings to interpolate undef variables as an empty string. This is the behavior present in 0.25.x.
Diffstat (limited to 'spec/unit/parser/ast')
-rwxr-xr-xspec/unit/parser/ast/leaf_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/unit/parser/ast/leaf_spec.rb b/spec/unit/parser/ast/leaf_spec.rb
index 6729cd278..5bdca67fa 100755
--- a/spec/unit/parser/ast/leaf_spec.rb
+++ b/spec/unit/parser/ast/leaf_spec.rb
@@ -50,6 +50,37 @@ describe Puppet::Parser::AST::String do
end
end
+describe Puppet::Parser::AST::Concat do
+ describe "when evaluating" do
+ before :each do
+ @scope = stub_everything 'scope'
+ end
+ it "should interpolate variables and concatenate their values" do
+ one = Puppet::Parser::AST::String.new(:value => "one")
+ one.stubs(:evaluate).returns("one ")
+ two = Puppet::Parser::AST::String.new(:value => "two")
+ two.stubs(:evaluate).returns(" two ")
+ three = Puppet::Parser::AST::String.new(:value => "three")
+ three.stubs(:evaluate).returns(" three")
+ var = Puppet::Parser::AST::Variable.new(:value => "myvar")
+ var.stubs(:evaluate).returns("foo")
+ array = Puppet::Parser::AST::Variable.new(:value => "array")
+ array.stubs(:evaluate).returns(["bar","baz"])
+ concat = Puppet::Parser::AST::Concat.new(:value => [one,var,two,array,three])
+
+ concat.evaluate(@scope).should == 'one foo two barbaz three'
+ end
+
+ it "should transform undef variables to empty string" do
+ var = Puppet::Parser::AST::Variable.new(:value => "myvar")
+ var.stubs(:evaluate).returns(:undef)
+ concat = Puppet::Parser::AST::Concat.new(:value => [var])
+
+ concat.evaluate(@scope).should == ''
+ end
+ end
+end
+
describe Puppet::Parser::AST::Undef do
before :each do
@scope = stub 'scope'