summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/parser.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-09-20 14:14:44 +0200
committerJames Turnbull <james@lovedthanlost.net>2008-09-21 02:32:51 +1000
commit7a3a38f58c099244c2a8b490f0b69c2fa63f3e16 (patch)
treec5bf762a1f3a7f9f0fa0a23eb442290e929e5a61 /spec/unit/parser/parser.rb
parent16793d221f95b2430260c38cd7c36bb8a5ef8d49 (diff)
downloadpuppet-7a3a38f58c099244c2a8b490f0b69c2fa63f3e16.tar.gz
puppet-7a3a38f58c099244c2a8b490f0b69c2fa63f3e16.tar.xz
puppet-7a3a38f58c099244c2a8b490f0b69c2fa63f3e16.zip
Add rspec unit test for the append operator
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser/parser.rb')
-rwxr-xr-xspec/unit/parser/parser.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb
new file mode 100755
index 000000000..94b19be40
--- /dev/null
+++ b/spec/unit/parser/parser.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Puppet::Parser do
+
+ AST = Puppet::Parser::AST
+
+ before :each do
+ @parser = Puppet::Parser::Parser.new :environment => "development"
+ end
+
+ describe "when parsing append operator" do
+
+ it "should not raise syntax errors" do
+ lambda { @parser.parse("$var += something") }.should_not raise_error
+ end
+
+ it "shouldraise syntax error on incomplete syntax " do
+ lambda { @parser.parse("$var += ") }.should raise_error
+ end
+
+ it "should call AST::VarDef with append=true" do
+ AST::VarDef.expects(:new).with { |h| h[:append] == true }
+ @parser.parse("$var += 2")
+ end
+
+ it "should work with arrays too" do
+ AST::VarDef.expects(:new).with { |h| h[:append] == true }
+ @parser.parse("$var += ['test']")
+ end
+
+ end
+end