From 73d04c6b15e1b626cd7dea1f963a5ca02a810137 Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Mon, 26 Oct 2009 00:43:29 -0700 Subject: Bug #2534 Raise error if property appears twice This patch changes Puppet::Parser::Resource to check if it has been passed two Puppet::Parser::Resource::Param objects with the same name. Signed-off-by: Jesse Wolfe --- spec/unit/parser/resource.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb index 0a67c4b54..3f08de958 100755 --- a/spec/unit/parser/resource.rb +++ b/spec/unit/parser/resource.rb @@ -25,7 +25,7 @@ describe Puppet::Parser::Resource do params = args[:params] || {:one => "yay", :three => "rah"} if args[:params] == :none args.delete(:params) - else + elsif not args[:params].is_a? Array args[:params] = paramify(args[:source], params) end @@ -483,5 +483,18 @@ describe Puppet::Parser::Resource do result = @parser_resource.to_resource result[:fee].should == ["a", Puppet::Resource::Reference.new(:file, "/my/file1"), Puppet::Resource::Reference.new(:file, "/my/file2")] end + + it "should fail if the same param is declared twice" do + lambda do + @parser_resource = mkresource :source => @source, :params => [ + Puppet::Parser::Resource::Param.new( + :name => :foo, :value => "bar", :source => @source + ), + Puppet::Parser::Resource::Param.new( + :name => :foo, :value => "baz", :source => @source + ) + ] + end.should raise_error(Puppet::ParseError) + end end end -- cgit