Sha256: 1f99a9cc0e49384401a701685e06efc90d996d090fce6b38e46c1d21cf97f4bd

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require File.expand_path('../test_helper', __FILE__)

describe "dante runner" do
  describe "with no daemonize" do
    before do
      @process = TestingProcess.new('a')
      @runner = Dante::Runner.new('test-process') { @process.run_a! }
      @stdout = capture_stdout { @runner.execute! }
    end

    it "prints correct stdout" do
      assert_match /Starting test-process/, @stdout
    end

    it "starts successfully when executed" do
      @output = File.read(@process.tmp_path)
      assert_match /Started/, @output
    end
  end # no daemonize

  describe "with daemonize flag" do
    before do
      @process = TestingProcess.new('b')
      @run_options = { :daemonize => true, :pid_path => "/tmp/dante.pid" }
      @runner = Dante::Runner.new('test-process-2', @run_options) { @process.run_b! }
      @stdout = capture_stdout { @runner.execute! }
      sleep(1)
    end

    it "can properly handles aborts and starts / stops on INT" do
      refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
      Process.kill "INT", @pid
      sleep(1) # Wait to complete
      @output = File.read(@process.tmp_path)
      assert_match /Started!!/, @output
      assert_match /Abort!!/, @output
      assert_match /Closing!!/, @output
    end

    it "can properly handles aborts and starts / stops on TERM" do
      refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
      Process.kill "TERM", @pid
      sleep(1) # Wait to complete
      @output = File.read(@process.tmp_path)
      assert_match /Started!!/, @output
      assert_match /Abort!!/, @output
      assert_match /Closing!!/, @output
    end
  end # daemonize
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dante-0.0.1 test/runner_test.rb