summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-13 08:05:11 -0500
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-13 08:05:11 -0500
commitf0ecbaa9c17fd86c7c28f6cda8c6f571fbccf17d (patch)
tree6f7adfe6b4c537c212ce29454668a066c31b721a
parent7c4fff28830fb63a3aa88fcdfb968af18c0cb6fd (diff)
downloadchef-f0ecbaa9c17fd86c7c28f6cda8c6f571fbccf17d.tar.gz
Added spec for check_resource_semantics! in
-rw-r--r--spec/unit/provider_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb
index 5a21b094d0..d7a34bc21b 100644
--- a/spec/unit/provider_spec.rb
+++ b/spec/unit/provider_spec.rb
@@ -49,6 +49,13 @@ class ConvergeActionDemonstrator < Chef::Provider
end
end
+class CheckResourceSemanticsDemonstrator < ConvergeActionDemonstrator
+ def check_resource_semantics!
+ raise Chef::Exceptions::InvalidResourceSpecification.new("check_resource_semantics!")
+ end
+end
+
+
describe Chef::Provider do
before(:each) do
@cookbook_collection = Chef::CookbookCollection.new([])
@@ -89,6 +96,10 @@ describe Chef::Provider do
expect(@provider.send(:whyrun_supported?)).to eql(false)
end
+ it "should do nothing for check_resource_semantics! by default" do
+ expect { @provider.check_resource_semantics! }.not_to raise_error
+ end
+
it "should return true for action_nothing" do
expect(@provider.action_nothing).to eql(true)
end
@@ -176,6 +187,15 @@ describe Chef::Provider do
expect(@resource).not_to be_updated_by_last_action
end
end
+
+ describe "and the resource is invalid" do
+ let(:provider) { CheckResourceSemanticsDemonstrator.new(@resource, @run_context) }
+
+ it "fails with InvalidResourceSpecification when run" do
+ expect { provider.run_action(:foo) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification)
+ end
+
+ end
end
end