[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:05:44 UTC 2009


The following commit has been merged in the upstream branch:
commit a5950339f43e08516130ff0b7463dbe3fa925890
Author: Markus Roberts <Markus at reality.com>
Date:   Fri Sep 18 16:12:08 2009 -0700

    Fix for #2654 (error generating error message)
    
    Since required_features can (and frequently does) return a single
    item instead of an Array, the error message needed to be more robust.
    
    The tests were not specific enough to catch the fact that an error
    was being raised in the generation of the error, so a more specific
    test was added and the required_features accessor test was beefed up
    a little.
    
    Signed-off-by: Markus Roberts <Markus at reality.com>
    
    Signed-off-by: Markus Roberts <Markus at reality.com>

diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index 1ed323f..abbc71c 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -1,4 +1,4 @@
- # The virtual base class for properties, which are the self-contained building
+# The virtual base class for properties, which are the self-contained building
 # blocks for actually doing work on the system.
 
 require 'puppet'
@@ -384,7 +384,7 @@ class Puppet::Property < Puppet::Parameter
     # Make sure that we've got all of the required features for a given value.
     def validate_features_per_value(value)
         if features = self.class.value_option(self.class.value_name(value), :required_features)
-            raise ArgumentError, "Provider must have features '%s' to set '%s' to '%s'" % [features.collect { |f| f.to_s }.join(", "), self.class.name, value] unless provider.satisfies?(features)
+            raise ArgumentError, "Provider must have features '%s' to set '%s' to '%s'" % [[features].flatten.join(", "), self.class.name, value] unless provider.satisfies?(features)
         end
     end
 
diff --git a/spec/unit/property.rb b/spec/unit/property.rb
index 07ab9c3..26a5765 100755
--- a/spec/unit/property.rb
+++ b/spec/unit/property.rb
@@ -34,10 +34,12 @@ describe Puppet::Property do
         @class.should respond_to(:required_features=)
     end
 
-    it "should always convert required features into an array of symbols" do
-        @class.required_features = %w{one two}
-        @class.required_features.should == [:one, :two]
-    end
+    {"one" => [:one],:one => [:one],%w{a} => [:a],[:b] => [:b],%w{one two} => [:one,:two],[:a,:b] => [:a,:b]}.each { |in_value,out_value|
+        it "should always convert required features into an array of symbols (e.g. #{in_value.inspect} --> #{out_value.inspect})" do
+            @class.required_features = in_value
+            @class.required_features.should == out_value
+        end
+    }
 
     it "should be able to shadow metaparameters" do
         @property.must respond_to(:shadow)
@@ -200,6 +202,14 @@ describe Puppet::Property do
             lambda { @property.should = :foo }.should raise_error(Puppet::Error)
         end
 
+        it "should internally raise an ArgumentError if required features are missing" do
+            @class.newvalue(:foo, :required_features => [:a, :b])
+
+            @provider.expects(:satisfies?).with([:a, :b]).returns false
+
+            lambda { @property.validate_features_per_value :foo }.should raise_error(ArgumentError)
+        end
+
         it "should validate that all required features are present for regexes" do
             value = @class.newvalue(/./, :required_features => [:a, :b])
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list