diff options
author | tyler-ball <tyleraball@gmail.com> | 2015-06-03 15:36:37 -0700 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2015-06-08 07:34:19 -0700 |
commit | b49d45b319f937fed57c49a57fc034d1f4696a39 (patch) | |
tree | acc7f0427629093db7ef09622dff6b4257a46fa3 /spec/unit/run_context_spec.rb | |
parent | eb590e371b5e5d3f4d1d201dd3f58e4351116f41 (diff) | |
download | chef-b49d45b319f937fed57c49a57fc034d1f4696a39.tar.gz |
These tests were accidently left out when I moved #2621 to mastertball/missed-tests
Diffstat (limited to 'spec/unit/run_context_spec.rb')
-rw-r--r-- | spec/unit/run_context_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb index eac5028bc1..e20ba63b72 100644 --- a/spec/unit/run_context_spec.rb +++ b/spec/unit/run_context_spec.rb @@ -190,4 +190,45 @@ describe Chef::RunContext do expect(run_context.reboot_requested?).to be_falsey end end + + describe "notifications" do + let(:notification) { Chef::Resource::Notification.new(nil, nil, notifying_resource) } + + shared_context "notifying resource is a Chef::Resource" do + let(:notifying_resource) { Chef::Resource.new("gerbil") } + + it "should be keyed off the resource name" do + run_context.send(setter, notification) + expect(run_context.send(getter, notifying_resource)).to eq([notification]) + end + end + + shared_context "notifying resource is a subclass of Chef::Resource" do + let(:declared_type) { :alpaca } + let(:notifying_resource) { + r = Class.new(Chef::Resource).new("guinea pig") + r.declared_type = declared_type + r + } + + it "should be keyed off the resource declared key" do + run_context.send(setter, notification) + expect(run_context.send(getter, notifying_resource)).to eq([notification]) + end + end + + describe "of the immediate kind" do + let(:setter) { :notifies_immediately } + let(:getter) { :immediate_notifications } + include_context "notifying resource is a Chef::Resource" + include_context "notifying resource is a subclass of Chef::Resource" + end + + describe "of the delayed kind" do + let(:setter) { :notifies_delayed } + let(:getter) { :delayed_notifications } + include_context "notifying resource is a Chef::Resource" + include_context "notifying resource is a subclass of Chef::Resource" + end + end end |