summaryrefslogtreecommitdiff
path: root/spec/unit/lwrp_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
-rw-r--r--spec/unit/lwrp_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index eaa58bf48c..bffec9cace 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -180,6 +180,67 @@ describe "LWRP" do
end
end
+ describe "when inheriting from LWRPBase" do
+ let(:parent) do
+ Class.new(Chef::Resource::LWRPBase) do
+ actions :eat, :sleep
+ default_action :eat
+ end
+ end
+
+ context "when the child does not defined the methods" do
+ let(:child) do
+ Class.new(parent)
+ end
+
+ it "delegates #actions to the parent" do
+ expect(child.actions).to eq([:eat, :sleep])
+ end
+
+ it "delegates #default_action to the parent" do
+ expect(child.default_action).to eq(:eat)
+ end
+ end
+
+ context "when the child does define the methods" do
+ let(:child) do
+ Class.new(parent) do
+ actions :dont_eat, :dont_sleep
+ default_action :dont_eat
+ end
+ end
+
+ it "does not delegate #actions to the parent" do
+ expect(child.actions).to eq([:dont_eat, :dont_sleep])
+ end
+
+ it "does not delegate #default_action to the parent" do
+ expect(child.default_action).to eq(:dont_eat)
+ end
+ end
+
+ context "when actions are already defined" do
+ let(:child) do
+ Class.new(parent) do
+ actions :eat
+ actions :sleep
+ actions :drink
+ end
+ end
+
+ def raise_if_deprecated!
+ if Chef::VERSION.split('.').first.to_i > 11
+ raise "This test should be removed and the associated code should be removed!"
+ end
+ end
+
+ it "ammends actions when they are already defined" do
+ raise_if_deprecated!
+ expect(child.actions).to eq([:eat, :sleep, :drink])
+ end
+ end
+ end
+
end
describe "Lightweight Chef::Provider" do