summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-10-28 14:15:08 +0100
committerBrice Figureau <brice-puppet@daysofwonder.com>2008-10-29 10:28:32 +0100
commit9f30306d2c768bad3327ecb7748669afb10cd4aa (patch)
tree94eb572fc97edd80968549bcb7fe599193bb09f0 /spec/unit/parser
parent649a9e009a3a5bd070051b972c2cf26989af8e8c (diff)
downloadpuppet-9f30306d2c768bad3327ecb7748669afb10cd4aa.tar.gz
puppet-9f30306d2c768bad3327ecb7748669afb10cd4aa.tar.xz
puppet-9f30306d2c768bad3327ecb7748669afb10cd4aa.zip
Fix #857 - Multiple class of the same name don't append code
The following manifest wasn't working: class one { notice('class one') } class one { notice('second class one') } include one It all boiled down to class code not being arrays. Encapsulating code in ASTArray when needed is enough to append code, because of the property of ASTArray to evaluate all their members in turn. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/parser.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb
index 07aad588d..077f93d98 100755
--- a/spec/unit/parser/parser.rb
+++ b/spec/unit/parser/parser.rb
@@ -171,6 +171,34 @@ describe Puppet::Parser do
it "should not raise errors with a trailing comma" do
lambda { @parser.parse("$a = [1,2,]") }.should_not raise_error
end
+ end
+
+ describe Puppet::Parser, "when instantiating class of same name" do
+
+ before :each do
+ @one = stub 'one', :is_a? => true
+ @one.stubs(:is_a?).with(AST::ASTArray).returns(false)
+ @one.stubs(:is_a?).with(AST).returns(true)
+
+ @two = stub 'two'
+ @two.stubs(:is_a?).with(AST::ASTArray).returns(false)
+ @two.stubs(:is_a?).with(AST).returns(true)
+ end
+
+ it "should return the first class" do
+
+ klass1 = @parser.newclass("one", { :code => @one })
+
+ @parser.newclass("one", { :code => @two }).should == klass1
+ end
+
+ it "should concatenate code" do
+ klass1 = @parser.newclass("one", { :code => @one })
+
+ @parser.newclass("one", { :code => @two })
+
+ klass1.code.children.should == [@one,@two]
+ end
end