summaryrefslogtreecommitdiff
path: root/spec/integration
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-06-08 13:31:40 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-06-08 13:31:40 -0700
commiteb1c36404da38801ca755deccfd754512dd74782 (patch)
treeab6264e3433e6226524da1fb889b36436cc8d70f /spec/integration
parentaa55fd1ade2ec9fd052e3eb0a66f8c6a1d894c19 (diff)
downloadchef-eb1c36404da38801ca755deccfd754512dd74782.tar.gz
Deprecate property namespace magic
This forces everyone to starting using new_resource.property_name instead of just property_name. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/recipes/accumulator_spec.rb12
-rw-r--r--spec/integration/recipes/resource_action_spec.rb25
-rw-r--r--spec/integration/recipes/resource_load_spec.rb26
3 files changed, 29 insertions, 34 deletions
diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb
index e6afe09b8c..4a193bd7f0 100644
--- a/spec/integration/recipes/accumulator_spec.rb
+++ b/spec/integration/recipes/accumulator_spec.rb
@@ -62,7 +62,7 @@ describe "Accumulators" do
default_action :create
action :create do
- email_alias address do
+ email_alias new_resource.address do
recipients new_resource.recipients
end
end
@@ -78,7 +78,7 @@ describe "Accumulators" do
default_action :create
action :create do
- nested address do
+ nested new_resource.address do
recipients new_resource.recipients
end
end
@@ -149,8 +149,8 @@ describe "Accumulators" do
delayed_action :create
end
end
- r.variables[:aliases][address] ||= []
- r.variables[:aliases][address] += new_resource.recipients
+ r.variables[:aliases][new_resource.address] ||= []
+ r.variables[:aliases][new_resource.address] += new_resource.recipients
end
EOM
@@ -164,7 +164,7 @@ describe "Accumulators" do
default_action :create
action :create do
- email_alias address do
+ email_alias new_resource.address do
recipients new_resource.recipients
end
end
@@ -180,7 +180,7 @@ describe "Accumulators" do
default_action :create
action :create do
- nested address do
+ nested new_resource.address do
recipients new_resource.recipients
end
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index 03331c8625..f5f2d4a764 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -416,6 +416,7 @@ module ResourceActionSpec
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
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
recipe = converge do
resource_action_spec_also_with_x "hi" do
x 1
@@ -423,34 +424,43 @@ module ResourceActionSpec
end
end
warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
- expect(warnings.size).to eq 1
+ expect(warnings.size).to eq 2
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 do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ recipe = converge do
resource_action_spec_also_with_x "hi" do
x 1
action :set_x_to_x_in_non_initializer
end
- end.to emit_no_warnings_or_errors
+ end
+ warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
+ expect(warnings.size).to eq 1 # the deprecation warning, not the property masking one
end
it "Using the enclosing resource to set x to 10 emits no warning" do
- expect_recipe do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ recipe = converge do
resource_action_spec_also_with_x "hi" do
x 1
action :set_x_to_10
end
- end.to emit_no_warnings_or_errors
+ end
+ warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
+ expect(warnings.size).to eq 1 # the deprecation warning, not the property masking one
end
it "Using the enclosing resource to set x to 10 emits no warning" do
- expect_recipe do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ recipe = converge do
r = resource_action_spec_also_with_x "hi"
r.x 1
r.action :set_x_to_10
- end.to emit_no_warnings_or_errors
+ end
+ warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
+ expect(warnings.size).to eq 1 # the deprecation warning, not the property masking one
end
end
@@ -496,6 +506,7 @@ module ResourceActionSpec
end
it "Raises an error when attempting to use a template in the action" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
expect_converge do
has_property_named_template "hi"
end.to raise_error(/Property `template` of `has_property_named_template\[hi\]` was incorrectly passed a block. Possible property-resource collision. To call a resource named `template` either rename the property or else use `declare_resource\(:template, ...\)`/)
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 791b83c23a..4fc14c0687 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -32,7 +32,7 @@ describe "Resource.load_current_value" do
@created
end
action :create do
- new_resource.class.created_x = x
+ new_resource.class.created_x = new_resource.x
end
end
result.resource_name resource_name
@@ -45,10 +45,10 @@ describe "Resource.load_current_value" do
context "with a resource with load_current_value" do
before :each do
resource_class.load_current_value do
- x "loaded #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
- select { |name, p| p.is_set?(self) }.
- map { |name, p| "#{name}=#{p.get(self)}" }.
- join(", ")})"
+ x "loaded #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }
+ .select { |name, p| p.is_set?(self) }
+ .map { |name, p| "#{name}=#{p.get(self)}" }
+ .join(", ")})"
end
end
@@ -119,22 +119,6 @@ describe "Resource.load_current_value" do
end
end
- context "and a resource with no values set" do
- let(:resource) do
- e = self
- r = nil
- converge do
- r = public_send(e.resource_name, "blah") do
- end
- end
- r
- end
-
- it "the provider accesses values from load_current_value" do
- expect(resource.class.created_x).to eq "loaded 1 (name=blah)"
- end
- end
-
let (:subresource_name) do
:"load_current_value_subresource_dsl#{Namer.current_index}"
end