summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-05-26 14:05:13 -0700
committerNick Lewis <nick@puppetlabs.com>2011-05-26 14:05:13 -0700
commit59e6be30f24dfb1011fbb242029b5ff61e19514c (patch)
tree0a1c23a95e4e2922d08a7dfdeaeaf39f968adbae /spec/unit/parser
parent996dc076e9ca61613f80fc79f0ffe667b14d1ebb (diff)
parent2ebd2d9eda3c556244cda1ae62da95965a92d79b (diff)
downloadpuppet-59e6be30f24dfb1011fbb242029b5ff61e19514c.tar.gz
puppet-59e6be30f24dfb1011fbb242029b5ff61e19514c.tar.xz
puppet-59e6be30f24dfb1011fbb242029b5ff61e19514c.zip
Merge branch '2.7rc' into 2.7.x
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/ast/resource_reference_spec.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/spec/unit/parser/ast/resource_reference_spec.rb b/spec/unit/parser/ast/resource_reference_spec.rb
index 627754dd1..4d1c191cf 100755
--- a/spec/unit/parser/ast/resource_reference_spec.rb
+++ b/spec/unit/parser/ast/resource_reference_spec.rb
@@ -9,21 +9,25 @@ describe Puppet::Parser::AST::ResourceReference do
@scope = Puppet::Parser::Scope.new
end
+ def ast_name(value)
+ Puppet::Parser::AST::Name.new(:value => value)
+ end
+
def newref(type, title)
- title = stub 'title', :safeevaluate => title
- ref = Puppet::Parser::AST::ResourceReference.new(:type => type, :title => title)
+ title_array = Puppet::Parser::AST::ASTArray.new(:children => [title])
+ ref = Puppet::Parser::AST::ResourceReference.new(:type => type, :title => title_array)
end
it "should correctly produce reference strings" do
- newref("File", "/tmp/yay").evaluate(@scope).to_s.should == "File[/tmp/yay]"
+ newref("File", ast_name("/tmp/yay")).evaluate(@scope).to_s.should == "File[/tmp/yay]"
end
it "should produce a single resource when the title evaluates to a string" do
- newref("File", "/tmp/yay").evaluate(@scope).should == Puppet::Resource.new("file", "/tmp/yay")
+ newref("File", ast_name("/tmp/yay")).evaluate(@scope).should == Puppet::Resource.new("file", "/tmp/yay")
end
it "should return an array of resources if given an array of titles" do
- titles = mock 'titles', :safeevaluate => ["title1","title2"]
+ titles = Puppet::Parser::AST::ASTArray.new(:children => [ast_name("title1"), ast_name("title2")])
ref = ast::ResourceReference.new( :title => titles, :type => "File" )
ref.evaluate(@scope).should == [
Puppet::Resource.new("file", "title1"),
@@ -31,6 +35,16 @@ describe Puppet::Parser::AST::ResourceReference do
]
end
+ it "should return an array of resources if given a variable containing an array of titles" do
+ @scope.setvar("my_files", ["foo", "bar"])
+ titles = Puppet::Parser::AST::Variable.new(:value => "my_files")
+ ref = newref('File', titles)
+ ref.evaluate(@scope).should == [
+ Puppet::Resource.new("file", "foo"),
+ Puppet::Resource.new("file", "bar")
+ ]
+ end
+
it "should return a correct representation when converting to string" do
type = stub 'type', :is_a? => true, :to_s => "file"
title = stub 'title', :is_a? => true, :to_s => "[/tmp/a, /tmp/b]"