Sha256: 9df14168ea3100f82b2864588f881b830944d02ab63d4012485d15bf07f11143

Contents?: true

Size: 1.12 KB

Versions: 16

Compression:

Stored size: 1.12 KB

Contents

#!/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", :unless => MCollective::Util.windows? do
        f = mock
        f.expects(:write).with(Process.pid)

        File.expects(:open).with("/nonexisting", "w").yields(f)

        r = mock
        r.expects(:main_loop)

        Runner.expects(:new).returns(r)
        UnixDaemon.expects(:daemonize).yields

        UnixDaemon.daemonize_runner("/nonexisting")
      end

      it "should not write a pid file unless requested", :unless => MCollective::Util.windows? do
        r = mock
        r.expects(:main_loop)

        UnixDaemon.expects(:daemonize).yields
        Runner.expects(:new).returns(r)
        File.expects(:open).never

        UnixDaemon.daemonize_runner(nil)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mcollective-client-2.8.7 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.5 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.6 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.4 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.3 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.2 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.1 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.8.0 spec/unit/mcollective/unix_daemon_spec.rb
mcollective-client-2.7.0 spec/unit/unix_daemon_spec.rb
mcollective-client-2.6.1 spec/unit/unix_daemon_spec.rb
mcollective-client-2.6.0 spec/unit/unix_daemon_spec.rb
mcollective-client-2.5.3 spec/unit/unix_daemon_spec.rb
mcollective-client-2.5.2 spec/unit/unix_daemon_spec.rb
mcollective-client-2.5.1 spec/unit/unix_daemon_spec.rb
mcollective-client-2.5.0 spec/unit/unix_daemon_spec.rb
mcollective-client-2.5.0.rc1 spec/unit/unix_daemon_spec.rb