diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-14 16:55:26 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-12-14 17:05:35 -0800 |
commit | fbf1f7d21c059d75b9978b34f9b9b5021c6dbfa3 (patch) | |
tree | d9f1f954ef252186680f5dcc9bb698426ca981d8 /spec/integration | |
parent | 491e99e796673b5a3762d5a47ed51fabf1b6f8f1 (diff) | |
download | chef-fbf1f7d21c059d75b9978b34f9b9b5021c6dbfa3.tar.gz |
Only warn about potentially duplicate properties during the resource initializerjk/reduce-property-dup-warning
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/recipes/resource_action_spec.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb index 0ea67ea5f2..17a1eb9acd 100644 --- a/spec/integration/recipes/resource_action_spec.rb +++ b/spec/integration/recipes/resource_action_spec.rb @@ -377,6 +377,15 @@ describe "Resource.action" do x x end end + def self.x_warning_line + __LINE__-4 + end + action :set_x_to_x_in_non_initializer do + r = resource_action_spec_with_x 'hi' do + x 10 + end + x_times_2 = r.x*2 + end action :set_x_to_10 do resource_action_spec_with_x 'hi' do x 10 @@ -384,6 +393,8 @@ describe "Resource.action" do end end + attr_reader :x_warning_line + it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do recipe = converge { resource_action_spec_also_with_x 'hi' do @@ -393,7 +404,16 @@ describe "Resource.action" do } warnings = recipe.logs.lines.select { |l| l =~ /warn/i } expect(warnings.size).to eq 1 - expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{__LINE__-19}/) + expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{ResourceActionSpecAlsoWithX.x_warning_line}/) + end + + it "Using the enclosing resource to set x to x outside the initializer emits no warning" do + expect_recipe { + resource_action_spec_also_with_x 'hi' do + x 1 + action :set_x_to_x_in_non_initializer + end + }.to emit_no_warnings_or_errors end it "Using the enclosing resource to set x to 10 emits no warning" do @@ -404,6 +424,14 @@ describe "Resource.action" do end }.to emit_no_warnings_or_errors end + + it "Using the enclosing resource to set x to 10 emits no warning" do + expect_recipe { + r = resource_action_spec_also_with_x 'hi' + r.x 1 + r.action :set_x_to_10 + }.to emit_no_warnings_or_errors + end end end |