diff options
author | John Keiser <john@johnkeiser.com> | 2015-06-16 11:14:20 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-16 11:14:20 -0700 |
commit | bc5227d5ac004800a30b7b1353fa7461b132f2cb (patch) | |
tree | 3b3b7ba372639dbdf744407289464957d49a95fc /spec | |
parent | b08c9010c387c762a6fa82fa9ae8c2a5e5c8594d (diff) | |
download | chef-bc5227d5ac004800a30b7b1353fa7461b132f2cb.tar.gz |
Ensure :nothing is in the list of allowed actions for an LWRP
Diffstat (limited to 'spec')
-rw-r--r-- | spec/integration/recipes/recipe_dsl_spec.rb | 44 | ||||
-rw-r--r-- | spec/unit/lwrp_spec.rb | 8 |
2 files changed, 48 insertions, 4 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 3f4bf9fd5f..05ae72e688 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -754,4 +754,48 @@ describe "Recipe DSL methods" do end end end + + before(:all) { Namer.current_index = 0 } + before { Namer.current_index += 1 } + + context "with an LWRP that declares actions" do + let(:resource_class) { + Class.new(Chef::Resource::LWRPBase) do + provides :"recipe_dsl_spec#{Namer.current_index}" + actions :create + end + } + let(:resource) { + resource_class.new("blah", run_context) + } + it "The actions are part of actions along with :nothing" do + expect(resource_class.actions).to eq [ :nothing, :create ] + end + it "The actions are part of allowed_actions along with :nothing" do + expect(resource.allowed_actions).to eq [ :nothing, :create ] + end + + context "and a subclass that declares more actions" do + let(:subresource_class) { + Class.new(Chef::Resource::LWRPBase) do + provides :"recipe_dsl_spec_sub#{Namer.current_index}" + actions :delete + end + } + let(:subresource) { + subresource_class.new("subblah", run_context) + } + + it "The parent class actions are not part of actions" do + expect(subresource_class.actions).to eq [ :nothing, :delete ] + end + it "The parent class actions are not part of allowed_actions" do + expect(subresource.allowed_actions).to eq [ :nothing, :delete ] + end + it "The parent class actions do not change" do + expect(resource_class.actions).to eq [ :nothing, :create ] + expect(resource.allowed_actions).to eq [ :nothing, :create ] + end + end + end end diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 34c6f6f1c5..83105ac233 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -409,13 +409,13 @@ describe "LWRP" do end end - context "when the child does not defined the methods" do + context "when the child does not define the methods" do let(:child) do Class.new(parent) end it "delegates #actions to the parent" do - expect(child.actions).to eq([:eat, :sleep]) + expect(child.actions).to eq([:nothing, :eat, :sleep]) end it "delegates #default_action to the parent" do @@ -432,7 +432,7 @@ describe "LWRP" do end it "does not delegate #actions to the parent" do - expect(child.actions).to eq([:dont_eat, :dont_sleep]) + expect(child.actions).to eq([:nothing, :dont_eat, :dont_sleep]) end it "does not delegate #default_action to the parent" do @@ -457,7 +457,7 @@ describe "LWRP" do it "amends actions when they are already defined" do raise_if_deprecated! - expect(child.actions).to eq([:eat, :sleep, :drink]) + expect(child.actions).to eq([:nothing, :eat, :sleep, :drink]) end end end |