summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-04-26 10:23:22 -0700
committerBryan McLellan <btm@opscode.com>2013-05-30 09:06:51 -0700
commit16e6c3c0bc62bc2a447b361757c689d4990c3523 (patch)
tree062d1397993f69f5d366999e156dd96f57a03d9a /spec/unit/resource_spec.rb
parent7d64b79f54c0af67e813a5cdfc8197c421ae0886 (diff)
downloadchef-16e6c3c0bc62bc2a447b361757c689d4990c3523.tar.gz
[CHEF-4135] Add tests for notification specification
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r--spec/unit/resource_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 701481e882..3505baf33c 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -590,6 +590,66 @@ describe Chef::Resource do
end
end
+
+ describe "when creating notifications" do
+
+ describe "with a string resource spec" do
+
+ it "creates a delayed notification when timing is not specified" do
+ @resource.notifies(:run, "execute[foo]")
+ @run_context.delayed_notification_collection.should have(1).notifications
+ end
+
+ it "creates a delayed notification when :delayed is not specified" do
+ @resource.notifies(:run, "execute[foo]", :delayed)
+ @run_context.delayed_notification_collection.should have(1).notifications
+ end
+
+ it "creates an immediate notification when :immediate is specified" do
+ @resource.notifies(:run, "execute[foo]", :immediate)
+ @run_context.immediate_notification_collection.should have(1).notifications
+ end
+
+ it "creates an immediate notification when :immediately is specified" do
+ @resource.notifies(:run, "execute[foo]", :immediately)
+ @run_context.immediate_notification_collection.should have(1).notifications
+ end
+
+ describe "with a syntax error in the resource spec" do
+
+ it "raises an exception immmediately" do
+ pending
+ end
+ end
+ end
+
+ describe "with a resource reference" do
+ before do
+ @notified_resource = Chef::Resource.new("punk", @run_context)
+ end
+
+ it "creates a delayed notification when timing is not specified" do
+ @resource.notifies(:run, @notified_resource)
+ @run_context.delayed_notification_collection.should have(1).notifications
+ end
+
+ it "creates a delayed notification when :delayed is not specified" do
+ @resource.notifies(:run, @notified_resource, :delayed)
+ @run_context.delayed_notification_collection.should have(1).notifications
+ end
+
+ it "creates an immediate notification when :immediate is specified" do
+ @resource.notifies(:run, @notified_resource, :immediate)
+ @run_context.immediate_notification_collection.should have(1).notifications
+ end
+
+ it "creates an immediate notification when :immediately is specified" do
+ @resource.notifies(:run, @notified_resource, :immediately)
+ @run_context.immediate_notification_collection.should have(1).notifications
+ end
+ end
+
+ end
end
describe Chef::Resource::Notification do