X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Funit%2Funix_daemon_spec.rb;fp=spec%2Funit%2Funix_daemon_spec.rb;h=57bb9a3dc754bf3912191ce256b634c966ab72f8;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/spec/unit/unix_daemon_spec.rb b/spec/unit/unix_daemon_spec.rb new file mode 100755 index 0000000..57bb9a3 --- /dev/null +++ b/spec/unit/unix_daemon_spec.rb @@ -0,0 +1,41 @@ +#!/usr/bin/env rspec + +require 'spec_helper' +require 'mcollective/unix_daemon' + +module MCollective + describe UnixDaemon do + describe "#daemonize_runner" do + it "should not run on the windows platform" do + Util.expects("windows?").returns(true) + expect { UnixDaemon.daemonize_runner }.to raise_error("The Unix Daemonizer can not be used on the Windows Platform") + end + + it "should write the pid file if requested" do + f = mock + f.expects(:write).with(Process.pid) + + File.expects(:open).with("/nonexisting", "w").yields(f) + + r = mock + r.expects(:run) + + Runner.expects(:new).returns(r) + UnixDaemon.expects(:daemonize).yields + + UnixDaemon.daemonize_runner("/nonexisting") + end + + it "should not write a pid file unless requested" do + r = mock + r.expects(:run) + + UnixDaemon.expects(:daemonize).yields + Runner.expects(:new).returns(r) + File.expects(:open).never + + UnixDaemon.daemonize_runner(nil) + end + end + end +end