[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:30:20 UTC 2010


The following commit has been merged in the upstream branch:
commit fd427a51bc2bd97656767acc7f6b48160f8e60c4
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Sat Nov 14 19:19:04 2009 +0100

    Raise an error when appending not a hash to a hash
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 12c645a..c32db35 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -340,6 +340,7 @@ class Puppet::Parser::Scope
             when Array
                 table[name] += value
             when Hash
+                raise ArgumentError, "Trying to append to a hash with something which is not a hash is unsupported" unless value.is_a?(Hash)
                 table[name].merge!(value)
             else
                 table[name] << value
diff --git a/spec/unit/parser/scope.rb b/spec/unit/parser/scope.rb
index 2f553e4..ba5f806 100755
--- a/spec/unit/parser/scope.rb
+++ b/spec/unit/parser/scope.rb
@@ -155,28 +155,33 @@ describe Puppet::Parser::Scope do
             lambda { @scope.setvar("var","1", :append => true) }.should raise_error(Puppet::ParseError)
         end
 
-        it "it should lookup current variable value" do
+        it "should lookup current variable value" do
             @scope.expects(:lookupvar).with("var").returns("2")
             @scope.setvar("var","1", :append => true)
         end
 
-        it "it should store the concatenated string '42'" do
+        it "should store the concatenated string '42'" do
             @topscope.setvar("var","4", :append => false)
             @scope.setvar("var","2", :append => true)
             @scope.lookupvar("var").should == "42"
         end
 
-        it "it should store the concatenated array [4,2]" do
+        it "should store the concatenated array [4,2]" do
             @topscope.setvar("var",[4], :append => false)
             @scope.setvar("var",[2], :append => true)
             @scope.lookupvar("var").should == [4,2]
         end
 
-        it "it should store the merged hash {a => b, c => d}" do
+        it "should store the merged hash {a => b, c => d}" do
             @topscope.setvar("var",{"a" => "b"}, :append => false)
             @scope.setvar("var",{"c" => "d"}, :append => true)
             @scope.lookupvar("var").should == {"a" => "b", "c" => "d"}
         end
+
+        it "should raise an error when appending a hash with something other than another hash" do
+            @topscope.setvar("var",{"a" => "b"}, :append => false)
+            lambda { @scope.setvar("var","not a hash", :append => true) }.should raise_error
+        end
     end
 
     describe "when calling number?" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list