From 00d5fe403d754e61ae32f01f6879dfc93bfa6111 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sun, 5 Oct 2008 18:52:20 +0200 Subject: Fix #1115 - Allow checking tags/classes from ERb templates Add to predefined variables to the ERB template space. "classes" and "tags" which provide arrays of all the defined classes and tags for a node. Signed-off-by: Brice Figureau --- spec/unit/parser/templatewrapper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/unit/parser/templatewrapper.rb') diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb index 2d4bd141b..20ea76921 100755 --- a/spec/unit/parser/templatewrapper.rb +++ b/spec/unit/parser/templatewrapper.rb @@ -55,6 +55,20 @@ describe Puppet::Parser::TemplateWrapper do tw.has_variable?("chicken").should eql(false) end + it "should allow you to retrieve the defined classes with classes" do + catalog = mock 'catalog', :classes => ["class1", "class2"] + @scope.expects(:catalog).returns( catalog ) + tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) + tw.classes().should == ["class1", "class2"] + end + + it "should allow you to retrieve the defined tags with tags" do + catalog = mock 'catalog', :tags => ["tag1", "tag2"] + @scope.expects(:catalog).returns( catalog ) + tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) + tw.tags().should == ["tag1","tag2"] + end + it "should set all of the scope's variables as instance variables" do template_mock = mock("template", :result => "woot!") File.expects(:read).with("/tmp/fake_template").returns("template contents") -- cgit