diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-03-05 12:24:49 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-03-05 12:24:49 -0800 |
commit | 9caa843c236f9e8812f5f30702ba0bf74bf655f6 (patch) | |
tree | 6ad4fca5db165eaa6ea4f800987abcfa64ba11e4 /spec/integration | |
parent | 5a4031299e9d74bfb500522801fa2fc8d0ffc8e1 (diff) | |
download | chef-9caa843c236f9e8812f5f30702ba0bf74bf655f6.tar.gz |
remove deprecated proprety namespace collisionslcg/remove-deprecated-namespace-collisions
require writing `new_resource.my_property` instead of just
`my_property` in provider code.
a surprise in this code was that methods directly on the
resource are all injected into the provider, and we never
deprecated that, because we didn't know about it.
that makes `action_class {}` helpers unnecessary, but causes
additional namespace pollution, but at least the methods declared
in the resource will lose to DSL methods (i.e. `def execute`
will not work).
but that also means that resources which are injected into the DSL
which overwrite resource methods in other cookbooks may break
their use in that cookbooks providers/action_classes.
we should probably deprecate that as well, but we didn't and
people probably found this behavior and used it.
i cleaned it up a bit and removed the methods on Chef::Resource
directly which polluted the provider class with all kinds of
bizzare crap methods (not_if and only_if were getting injected
into the provider, etc).
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/recipes/resource_action_spec.rb | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb index d6ea4347c4..149b17fcad 100644 --- a/spec/integration/recipes/resource_action_spec.rb +++ b/spec/integration/recipes/resource_action_spec.rb @@ -378,94 +378,6 @@ module ResourceActionSpec end end - context "With a resource with property x" do - class ResourceActionSpecWithX < Chef::Resource - resource_name :resource_action_spec_with_x - property :x, default: 20 - action :set do - # Access x during converge to ensure that we emit no warnings there - x - end - end - - context "And another resource with a property x and an action that sets property x to its value" do - class ResourceActionSpecAlsoWithX < Chef::Resource - resource_name :resource_action_spec_also_with_x - property :x - action :set_x_to_x do - resource_action_spec_with_x "hi" 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 - end - 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 - 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 - end - end - warnings = recipe.logs.lines.select { |l| l =~ /warn/i } - 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 - 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 - 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 - 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 - 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 - 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 - 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 - - end - context "With a resource with a set_or_return property named group (same name as a resource)" do class ResourceActionSpecWithGroupAction < Chef::Resource resource_name :resource_action_spec_set_group_to_nil @@ -504,13 +416,6 @@ module ResourceActionSpec end end 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, ...\)`/) - end end context "When a resource declares methods in action_class" do |