diff options
Diffstat (limited to 'spec/unit/parser/templatewrapper.rb')
-rwxr-xr-x | spec/unit/parser/templatewrapper.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb index 20ea76921..6dbfbe266 100755 --- a/spec/unit/parser/templatewrapper.rb +++ b/spec/unit/parser/templatewrapper.rb @@ -62,10 +62,16 @@ describe Puppet::Parser::TemplateWrapper do tw.classes().should == ["class1", "class2"] end - it "should allow you to retrieve the defined tags with tags" do + it "should allow you to retrieve all the tags with all_tags" do catalog = mock 'catalog', :tags => ["tag1", "tag2"] @scope.expects(:catalog).returns( catalog ) tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) + tw.all_tags().should == ["tag1","tag2"] + end + + it "should allow you to retrieve the tags defined in the current scope" do + @scope.expects(:tags).returns( ["tag1", "tag2"] ) + tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) tw.tags().should == ["tag1","tag2"] end @@ -78,5 +84,18 @@ describe Puppet::Parser::TemplateWrapper do @tw.result @tw.instance_variable_get("@one").should == "foo" - end + end + + %w{! . ; :}.each do |badchar| + it "should translate #{badchar} to _ when setting the instance variables" do + template_mock = mock("template", :result => "woot!") + File.expects(:read).with("/tmp/fake_template").returns("template contents") + ERB.expects(:new).with("template contents", 0, "-").returns(template_mock) + + @scope.expects(:to_hash).returns("one#{badchar}" => "foo") + @tw.result + + @tw.instance_variable_get("@one_").should == "foo" + end + end end |