diff options
-rw-r--r-- | lib/chef/mixin/provides.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider_resolver.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider_resolver_spec.rb | 4 |
3 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/mixin/provides.rb b/lib/chef/mixin/provides.rb index e5bb2c2005..bc25af62b2 100644 --- a/lib/chef/mixin/provides.rb +++ b/lib/chef/mixin/provides.rb @@ -25,6 +25,7 @@ class Chef # provides a node on the resource (early binding) def provides?(node, resource_name) + resource_name = resource_name.resource_name if resource_name.is_a?(Chef::Resource) node_map.get(node, resource_name) end end diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb index 867c3deca8..45122d7156 100644 --- a/lib/chef/provider_resolver.rb +++ b/lib/chef/provider_resolver.rb @@ -47,7 +47,9 @@ class Chef def enabled_handlers @enabled_handlers ||= providers.select do |klass| - klass.provides?(node, resource.resource_name) + # NB: this is different from resoruce_resolver which must pass a resource_name + # FIXME: deprecate this and normalize on passing resource_name here + klass.provides?(node, resource) end.sort {|a,b| a.to_s <=> b.to_s } end diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb index 718eebfdf4..bdf6d06e09 100644 --- a/spec/unit/provider_resolver_spec.rb +++ b/spec/unit/provider_resolver_spec.rb @@ -46,6 +46,10 @@ describe Chef::ProviderResolver do let(:resource) { double(Chef::Resource, provider: provider, resource_name: resource_name) } + before do + allow(resource).to receive(:is_a?).with(Chef::Resource).and_return(true) + end + describe "resolving service resource" do def stub_service_providers(*services) services ||= [] |