summaryrefslogtreecommitdiff
path: root/spec/unit/chef_class_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/chef_class_spec.rb')
-rw-r--r--spec/unit/chef_class_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb
index 2528246be6..65a637dcbb 100644
--- a/spec/unit/chef_class_spec.rb
+++ b/spec/unit/chef_class_spec.rb
@@ -88,4 +88,27 @@ describe "Chef class" do
expect(Chef.node).to eql(node)
end
end
+
+ context '#event_handler' do
+ it 'adds a new handler' do
+ x = 1
+ Chef.event_handler do
+ on :converge_start do
+ x = 2
+ end
+ end
+ expect(Chef::Config[:event_handlers]).to_not be_empty
+ Chef::Config[:event_handlers].first.send(:converge_start)
+ expect(x).to eq(2)
+ end
+
+ it 'raise error if unknown event type is passed' do
+ expect do
+ Chef.event_handler do
+ on :yolo do
+ end
+ end
+ end.to raise_error(Chef::Exceptions::UnknownEventType)
+ end
+ end
end