summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2015-06-29 11:04:45 -0700
committerNoah Kantrowitz <noah@coderanger.net>2015-06-29 11:04:45 -0700
commita607109dd188ebbb762b3b2c38c588101765f493 (patch)
treec8df66375d747f1afdd1a9aea38dca077b4c2d9d
parentc8174db52dab1daef2b8dc22a591b890b54f98f5 (diff)
downloadchef-a607109dd188ebbb762b3b2c38c588101765f493.tar.gz
Tests for new default_action behaviors.
-rw-r--r--spec/unit/resource_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index a2bd78c783..fad68552b7 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -991,6 +991,15 @@ describe Chef::Resource do
it { is_expected.to eq [:nothing] }
end
+ context "with a default action" do
+ let(:resource_class) do
+ Class.new(described_class) do
+ default_action(:one)
+ end
+ end
+ it { is_expected.to eq [:one] }
+ end
+
context "with a symbol action" do
before { resource.action(:one) }
it { is_expected.to eq [:one] }
@@ -1019,4 +1028,34 @@ describe Chef::Resource do
it { expect { resource.action = :three }.to raise_error Chef::Exceptions::ValidationFailed }
end
end
+
+ describe ".default_action" do
+ let(:default_action) { }
+ let(:resource_class) do
+ actions = default_action
+ Class.new(described_class) do
+ default_action(actions) if actions
+ end
+ end
+ subject { resource_class.default_action }
+
+ context "with no default actions" do
+ it { is_expected.to eq [:nothing] }
+ end
+
+ context "with a symbol default action" do
+ let(:default_action) { :one }
+ it { is_expected.to eq [:one] }
+ end
+
+ context "with a string default action" do
+ let(:default_action) { 'one' }
+ it { is_expected.to eq [:one] }
+ end
+
+ context "with an array default action" do
+ let(:default_action) { [:two, :one] }
+ it { is_expected.to eq [:two, :one] }
+ end
+ end
end