diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-06 14:24:00 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-05-13 13:43:14 -0700 |
commit | 2032c6776587f9450ddba182867973ab5bee1b75 (patch) | |
tree | 907d2c3a62a7dbafc78c26e7fd6d4677a9a8d3b4 | |
parent | c0ab4749e58ad00a4ccbb397fc1cce8c9763370a (diff) | |
download | chef-2032c6776587f9450ddba182867973ab5bee1b75.tar.gz |
Fix deprecation warning (and corresponding test) for Chef::Resource::Blah
-rw-r--r-- | lib/chef/resource.rb | 7 | ||||
-rw-r--r-- | spec/integration/recipes/recipe_dsl_spec.rb | 11 |
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 565313e3e1..d5a1876943 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1129,13 +1129,12 @@ class Chef # @deprecated Chef::Resource::FooBar will no longer mean anything special in # Chef 13. Use `resource_for_node` instead. def self.resource_matching_short_name(short_name) - require 'chef/resource_resolver' begin rname = convert_to_class_name(short_name.to_s) result = Chef::Resource.const_get(rname) - if result.is_a?(Chef::Resource) - Chef::Log.deprecation("Class Chef::Resource::#{rname} does not declare `provides #{short_name.inspect}`.") - Chef::Log.deprecation("This will no longer work in Chef 13: you must use `provides` to provide DSL.") + if result <= Chef::Resource + Chef::Log.deprecation("Class Chef::Resource::#{rname} does not declare 'provides #{short_name.inspect}'.") + Chef::Log.deprecation("This will no longer work in Chef 13: you must use 'provides' to provide DSL.") result end rescue NameError diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 99b32eb3f1..66eeb62ae8 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -44,6 +44,10 @@ describe "Recipe DSL methods" do end context "Deprecated automatic resource DSL" do + before do + Chef::Config[:treat_deprecation_warnings_as_errors] = false + end + context "With a resource 'backcompat_thingy' declared in Chef::Resource and Chef::Provider" do before(:context) { @@ -70,7 +74,7 @@ describe "Recipe DSL methods" do recipe = converge { backcompat_thingy 'blah' do; end } - expect(recipe.logged_warnings).to match /Chef::Resource/i + expect(recipe.logged_warnings).to match /Class Chef::Resource::BackcompatThingy does not declare 'provides :backcompat_thingy'/i expect(BaseThingy.created_resource).to eq Chef::Resource::BackcompatThingy expect(BaseThingy.created_provider).to eq Chef::Provider::BackcompatThingy end @@ -84,12 +88,11 @@ describe "Recipe DSL methods" do } - it "backcompat_thingy creates a BackcompatThingy and warns about ambiguity" do + it "backcompat_thingy creates a BackcompatThingy" do recipe = converge { backcompat_thingy 'blah' do; end } - expect(recipe.logged_warnings).to match /Chef::Resource/i - expect(recipe.logged_warnings).to match /ambiguous resource precedence/i + expect(recipe.logged_warnings).to eq '' expect(BaseThingy.created_resource).not_to be_nil end end |