summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-07-01 11:25:29 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-07-01 11:25:29 -0700
commit0bdd358decddf4251c20ced1eb48e54057eb2418 (patch)
tree8b14ee89ad80558f59b8acea81ef6e7c5863f1fd /spec
parenta39ae423bbfc72f4b26c4ed2435c4b625e176e6e (diff)
downloadchef-0bdd358decddf4251c20ced1eb48e54057eb2418.tar.gz
tweak 3694 warnings
- clean up "ZenMaster" resource - clean up 3694 detection to use properties - unlazy the resource_name in the trivial resource check - fixes an issue with resources-as-definitions pattern emitting 3694 errors for trivial resources
Diffstat (limited to 'spec')
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb14
-rw-r--r--spec/unit/recipe_spec.rb21
2 files changed, 23 insertions, 12 deletions
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index f5137c18ec..4b94e7415c 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -24,18 +24,8 @@ class Chef
class ZenMaster < Chef::Resource
allowed_actions :win, :score
- attr_reader :peace
-
- def peace(tf)
- @peace = tf
- end
-
- def something(arg = nil)
- if !arg.nil?
- @something = arg
- end
- @something
- end
+ property :peace
+ property :something
end
end
end
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 70164f0a9b..3c30f96b20 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -266,6 +266,27 @@ describe Chef::Recipe do
end
end
+ class Coerced < Chef::Resource
+ resource_name :coerced
+ provides :coerced
+ default_action :whatever
+ property :package_name, [String, Array], coerce: proc { |x| [x].flatten }, name_property: true
+ def after_created
+ Array(action).each do |action|
+ run_action(action)
+ end
+ end
+ action :whatever do
+ package_name # unlazy the package_name
+ end
+ end
+
+ it "does not emit 3694 when the name_property is unlazied by running it at compile_time" do
+ recipe.coerced "string"
+ expect(Chef).to_not receive(:log_deprecation)
+ recipe.coerced "string"
+ end
+
it "validating resources via build_resource" do
expect {recipe.build_resource(:remote_file, "klopp") do
source Chef::DelayedEvaluator.new { "http://chef.io" }