diff options
Diffstat (limited to 'spec/unit/client_spec.rb')
-rw-r--r-- | spec/unit/client_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 02e30e0c3b..0568da6eaf 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -263,6 +263,25 @@ shared_examples_for Chef::Client do end end + it "should remove the run_lock on failure of #load_node" do + @run_lock = mock("Chef::RunLock", :acquire => true) + Chef::RunLock.stub!(:new).and_return(@run_lock) + + @events = mock("Chef::EventDispatch::Dispatcher").as_null_object + Chef::EventDispatch::Dispatcher.stub!(:new).and_return(@events) + + # @events is created on Chef::Client.new, so we need to recreate it after mocking + @client = Chef::Client.new + @client.stub!(:load_node).and_raise(Exception) + @run_lock.should_receive(:release) + if(Chef::Config[:client_fork]) + @client.should_receive(:fork) do |&block| + block.call + end + end + lambda { @client.run }.should raise_error(Exception) + end + describe "when notifying other objects of the status of the chef run" do before do Chef::Client.clear_notifications |