summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-03-23 10:00:11 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit2777e1f052a51f0f52086cdfbea790902b0cecdc (patch)
tree5eb6f67fec42bcefff6022838631445b5753ca46
parent5aa26d08892010fc62de6adc278f07c8748d75e0 (diff)
downloadpuppet-2777e1f052a51f0f52086cdfbea790902b0cecdc.tar.gz
puppet-2777e1f052a51f0f52086cdfbea790902b0cecdc.tar.xz
puppet-2777e1f052a51f0f52086cdfbea790902b0cecdc.zip
Fixing feature validation when passed one item
When I changed how the validation errors worked I accidentally caused the feature list to need to be an array rather than supporting either. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
-rw-r--r--lib/puppet/property.rb1
-rwxr-xr-xspec/unit/property.rb8
-rwxr-xr-xspec/unit/type/package.rb12
-rwxr-xr-xspec/unit/type/user.rb2
4 files changed, 16 insertions, 7 deletions
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index b96f6d120..4b58abd1f 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -333,6 +333,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)
+ features = Array(features)
needed_features = features.collect { |f| f.to_s }.join(", ")
raise ArgumentError, "Provider must have features '#{needed_features}' to set '#{self.class.name}' to '#{value}'" unless provider.satisfies?(features)
end
diff --git a/spec/unit/property.rb b/spec/unit/property.rb
index af3dbc408..64bad19d1 100755
--- a/spec/unit/property.rb
+++ b/spec/unit/property.rb
@@ -325,6 +325,14 @@ describe Puppet::Property do
@property.should = "foo"
end
+
+ it "should support specifying an individual required feature" do
+ value = @class.newvalue(/./, :required_features => :a)
+
+ @provider.expects(:satisfies?).returns true
+
+ @property.should = "foo"
+ end
end
describe "when munging values" do
diff --git a/spec/unit/type/package.rb b/spec/unit/type/package.rb
index b76374eba..11bd59778 100755
--- a/spec/unit/type/package.rb
+++ b/spec/unit/type/package.rb
@@ -61,32 +61,32 @@ describe Puppet::Type.type(:package), "when validating attribute values" do
end
it "should support :purged as a value to :ensure if the provider has the :purgeable feature" do
- @provider.expects(:satisfies?).with(:purgeable).returns(true)
+ @provider.expects(:satisfies?).with([:purgeable]).returns(true)
Puppet::Type.type(:package).new(:name => "yay", :ensure => :purged)
end
it "should not support :purged as a value to :ensure if the provider does not have the :purgeable feature" do
- @provider.expects(:satisfies?).with(:purgeable).returns(false)
+ @provider.expects(:satisfies?).with([:purgeable]).returns(false)
proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => :purged) }.should raise_error(Puppet::Error)
end
it "should support :latest as a value to :ensure if the provider has the :upgradeable feature" do
- @provider.expects(:satisfies?).with(:upgradeable).returns(true)
+ @provider.expects(:satisfies?).with([:upgradeable]).returns(true)
Puppet::Type.type(:package).new(:name => "yay", :ensure => :latest)
end
it "should not support :latest as a value to :ensure if the provider does not have the :upgradeable feature" do
- @provider.expects(:satisfies?).with(:upgradeable).returns(false)
+ @provider.expects(:satisfies?).with([:upgradeable]).returns(false)
proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => :latest) }.should raise_error(Puppet::Error)
end
it "should support version numbers as a value to :ensure if the provider has the :versionable feature" do
- @provider.expects(:satisfies?).with(:versionable).returns(true)
+ @provider.expects(:satisfies?).with([:versionable]).returns(true)
Puppet::Type.type(:package).new(:name => "yay", :ensure => "1.0")
end
it "should not support version numbers as a value to :ensure if the provider does not have the :versionable feature" do
- @provider.expects(:satisfies?).with(:versionable).returns(false)
+ @provider.expects(:satisfies?).with([:versionable]).returns(false)
proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => "1.0") }.should raise_error(Puppet::Error)
end
diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb
index deabd4746..3d4d49dca 100755
--- a/spec/unit/type/user.rb
+++ b/spec/unit/type/user.rb
@@ -254,7 +254,7 @@ describe user do
describe "when manages_solaris_rbac is enabled" do
before do
@provider.stubs(:satisfies?).returns(false)
- @provider.expects(:satisfies?).with(:manages_solaris_rbac).returns(true)
+ @provider.expects(:satisfies?).with([:manages_solaris_rbac]).returns(true)
end
it "should support a :role value for ensure" do