Update mcollective.init according to OSCI-855
[packages/precise/mcollective.git] / spec / unit / windows_daemon_spec.rb
1 #!/usr/bin/env rspec
2
3 require 'spec_helper'
4
5 module MCollective
6   if Util.windows?
7     require 'mcollective/windows_daemon'
8
9     describe WindowsDaemon do
10       describe "#daemonize_runner" do
11         it "should only run on the windows platform" do
12           Util.expects("windows?").returns(false)
13           expect { WindowsDaemon.daemonize_runner }.to raise_error("The Windows Daemonizer should only be used on the Windows Platform")
14         end
15
16         it "should not support writing pid files" do
17           expect { WindowsDaemon.daemonize_runner(true) }.to raise_error("Writing pid files are not supported on the Windows Platform")
18         end
19
20         it "should start the mainloop" do
21           WindowsDaemon.expects(:mainloop)
22           WindowsDaemon.daemonize_runner
23         end
24       end
25
26       describe "#service_stop" do
27         it "should disconnect and exit" do
28           Log.expects(:info)
29
30           connector = mock
31           connector.expects(:disconnect).once
32
33           PluginManager.expects("[]").with("connector_plugin").returns(connector)
34
35           d = WindowsDaemon.new
36           d.expects("exit!").once
37
38           d.service_stop
39         end
40       end
41     end
42   end
43 end