summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-10-21 19:28:21 +0200
committerLuke Kanies <luke@madstop.com>2008-10-21 19:28:21 +0200
commitb7d72360f66e36d897cfd4436236a3607a6de5b7 (patch)
treef0e7be01442451f10574e9499268c2012be81988 /spec/unit
parentfe789798cc0ccdc54b3a28d48bf206c9fc187085 (diff)
parent6d05cbc1e1a22d4316e18fb22d5cff9c7a42d3cf (diff)
Merge branch '0.24.x' of git://github.com/jamtur01/puppet into 0.24.x
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/parser/parser.rb32
-rwxr-xr-xspec/unit/parser/templatewrapper.rb23
2 files changed, 53 insertions, 2 deletions
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb
index c0d22a2cc..07aad588d 100755
--- a/spec/unit/parser/parser.rb
+++ b/spec/unit/parser/parser.rb
@@ -142,4 +142,36 @@ describe Puppet::Parser do
end
+ describe Puppet::Parser, "when parsing function calls" do
+
+ it "should not raise errors with no arguments" do
+ lambda { @parser.parse("tag()") }.should_not raise_error
+ end
+
+ it "should not raise errors with rvalue function with no args" do
+ lambda { @parser.parse("$a = template()") }.should_not raise_error
+ end
+
+ it "should not raise errors with arguments" do
+ lambda { @parser.parse("notice(1)") }.should_not raise_error
+ end
+
+ it "should not raise errors with multiple arguments" do
+ lambda { @parser.parse("notice(1,2)") }.should_not raise_error
+ end
+
+ it "should not raise errors with multiple arguments and a trailing comma" do
+ lambda { @parser.parse("notice(1,2,)") }.should_not raise_error
+ end
+
+ end
+
+ describe Puppet::Parser, "when parsing arrays with trailing comma" do
+
+ it "should not raise errors with a trailing comma" do
+ lambda { @parser.parse("$a = [1,2,]") }.should_not raise_error
+ end
+
+ end
+
end
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