diff options
| -rw-r--r-- | lib/puppet/type.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/type/service_spec.rb | 8 | ||||
| -rwxr-xr-x | test/ral/manager/attributes.rb | 21 | ||||
| -rwxr-xr-x | test/ral/manager/type.rb | 2 |
4 files changed, 12 insertions, 25 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index f6b0282c3..2aeec82d8 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -496,12 +496,6 @@ class Type return @parameters[name] end - if provider and ! provider.class.supports_parameter?(klass) - missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) } - info "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name] - return nil - end - begin # make sure the parameter doesn't have any errors return @parameters[name] = klass.new(:resource => self) diff --git a/spec/unit/type/service_spec.rb b/spec/unit/type/service_spec.rb index f09ed98b9..48d87ba61 100755 --- a/spec/unit/type/service_spec.rb +++ b/spec/unit/type/service_spec.rb @@ -76,18 +76,10 @@ describe Puppet::Type.type(:service), "when validating attribute values" do it "should allow setting the :enable parameter if the provider has the :enableable feature" do Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true) - Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(true) svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true) svc.should(:enable).should == :true end - it "should not allow setting the :enable parameter if the provider is missing the :enableable feature" do - Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true) - Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(false) - svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true) - svc.should(:enable).should be_nil - end - it "should split paths on ':'" do FileTest.stubs(:exist?).returns(true) FileTest.stubs(:directory?).returns(true) diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index cf8f2f9ae..5ddd27f97 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -115,12 +115,16 @@ class TestTypeAttributes < Test::Unit::TestCase # Now set each of them attr_check(type) do |inst, klass| - inst.newattr(klass.name, :value => "value") + property = inst.newattr(klass.name) + property.value = "value" + property end # Now try it passing the class in attr_check(type) do |inst, klass| - inst.newattr(klass, :value => "value") + property = inst.newattr(klass) + property.value = "value" + property end # Lastly, make sure we can create and then set, separately @@ -131,10 +135,9 @@ class TestTypeAttributes < Test::Unit::TestCase end # Make sure we can't create a new param object - assert_raise(Puppet::Error, - "Did not throw an error when replacing attr") do - inst.newattr(klass.name, :value => "yay") - end + new_attr = inst.newattr(klass.name) + assert_equal(new_attr, obj, "newattr should return the same object if called a second time") + obj end end @@ -221,10 +224,7 @@ class TestTypeAttributes < Test::Unit::TestCase end yes.each { |a| assert(resource.should(a), "Did not get value for %s in %s" % [a, prov.name]) } no.each do |a| - assert_nil(resource.should(a), "Got value for unsupported %s in %s" % [a, prov.name]) - if Puppet::Util::Log.sendlevel?(:info) - assert(@logs.find { |l| l.message =~ /not managing attribute #{a}/ and l.level == :info }, "No warning about failed %s" % a) - end + # These may or may not get passed to the provider. We shouldn't care. end @logs.clear @@ -288,6 +288,7 @@ class TestTypeAttributes < Test::Unit::TestCase cleanup { Puppet::Type.rmtype(:unsupported) } obj = type.new(:name => "test", :check => :yep) + obj.stubs(:newattr).returns(stub_everything("newattr")) obj.expects(:newattr).with(:nope).never obj[:check] = :all end diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb index ff3d0b0d2..f1dc437fd 100755 --- a/test/ral/manager/type.rb +++ b/test/ral/manager/type.rb @@ -65,7 +65,7 @@ class TestType < Test::Unit::TestCase :ensure => "file" ) - assert_raise(Puppet::Error, "Did not fail to alias when no catalog was available") { + assert_raise(Puppet::DevError, "It should fail to alias when no catalog was available") { resource[:alias] = "funtest" } end |
