diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-06-24 17:37:59 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-06-24 19:04:51 -0700 |
commit | dbb2e0c36d2585dc10eafd3c73f0af09ff0ff52a (patch) | |
tree | ec1bf09018721db603f9ec6226bb0b4fb6c5c72b /spec/integration | |
parent | ab34e3cd83d545b5da19113d723eeebcab1e77e2 (diff) | |
download | chef-dbb2e0c36d2585dc10eafd3c73f0af09ff0ff52a.tar.gz |
Fix to allow LW resources to be used with HW providersjdm/lwrp-fix
This should fix sethvargo-cookbooks/swap#22
Here's what was happening:
The cookbooks creates a Resource using the LWRP base. This dynamically
creates a class. We used to create this class with the name
Chef::Resource::SomeResourceName. In 12.4, this change to something like
"LWRP resource some_resource_name from cookbook CookbookName". When
searching for a provider, it couldn't be found because it wasn't explicitly
set, as it would have been if it was a LW provider, and it wasn't found
in Chef::Provider, because Chef::Provider had a provider SomeResourceName
instead of "LWRP resource some_resource_name from cookbook CookbookName".
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/recipes/recipe_dsl_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 6bbb9a5c4c..5426dce080 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -969,4 +969,29 @@ describe "Recipe DSL methods" do end end end + + context "with a dynamically defined resource and regular provider" do + before(:context) do + Class.new(Chef::Resource) do + resource_name :lw_resource_with_hw_provider_test_case + default_action :create + attr_accessor :created_provider + end + class Chef::Provider::LwResourceWithHwProviderTestCase < Chef::Provider + def load_current_resource + end + def action_create + new_resource.created_provider = self.class + end + end + end + + it "looks up the provider in Chef::Provider converting the resource name from snake case to camel case" do + resource = nil + recipe = converge { + resource = lw_resource_with_hw_provider_test_case 'blah' do; end + } + expect(resource.created_provider).to eq(Chef::Provider::LwResourceWithHwProviderTestCase) + end + end end |