diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2008-10-04 00:16:17 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-10-05 14:53:13 +1100 |
| commit | 79bb1f201c1479a15fa2f0f8ad5467bd357ed707 (patch) | |
| tree | 6887338bab7a90d4ca1f4e56282e4baeddc63673 /spec/unit/parser/parser.rb | |
| parent | 750e9abc64af58e547e7b1ad5698c71feb071bf6 (diff) | |
| download | puppet-79bb1f201c1479a15fa2f0f8ad5467bd357ed707.tar.gz puppet-79bb1f201c1479a15fa2f0f8ad5467bd357ed707.tar.xz puppet-79bb1f201c1479a15fa2f0f8ad5467bd357ed707.zip | |
Rspec Tests for #381.
Moved part of the old resource reference tests to rspec.
Diffstat (limited to 'spec/unit/parser/parser.rb')
| -rwxr-xr-x | spec/unit/parser/parser.rb | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb index 17e80bb6a..0092a9970 100755 --- a/spec/unit/parser/parser.rb +++ b/spec/unit/parser/parser.rb @@ -76,5 +76,44 @@ describe Puppet::Parser do lambda { @parser.parse("if (1 > 2 > ) or (1 == 2) { $var = 1 }") }.should raise_error end - end + end + + describe Puppet::Parser, "when parsing resource references" do + + it "should not raise syntax errors" do + lambda { @parser.parse('exec { test: param => File["a"] }') }.should_not raise_error + end + + it "should not raise syntax errors with multiple references" do + lambda { @parser.parse('exec { test: param => File["a","b"] }') }.should_not raise_error + end + + it "should create an AST::ResourceReference" do + AST::Resource.stubs(:new) + AST::ResourceReference.expects(:new).with { |arg| + arg[:line]==1 and arg[:type]=="File" and arg[:title].is_a?(AST::ASTArray) + } + @parser.parse('exec { test: command => File["a","b"] }') + end + end + + describe Puppet::Parser, "when parsing resource overrides" do + + it "should not raise syntax errors" do + lambda { @parser.parse('Resource["title"] { param => value }') }.should_not raise_error + end + + it "should not raise syntax errors with multiple overrides" do + lambda { @parser.parse('Resource["title1","title2"] { param => value }') }.should_not raise_error + end + + it "should create an AST::ResourceOverride" do + AST::ResourceOverride.expects(:new).with { |arg| + arg[:line]==1 and arg[:object].is_a?(AST::ResourceReference) and arg[:params].is_a?(AST::ResourceParam) + } + @parser.parse('Resource["title1","title2"] { param => value }') + end + + end + end |
