Sha256: c295f0aa6d56f64f7affc083801c610e7965bacd33bd0133f5e58d118ca2ef1e

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestConditionsProcessRunning < Test::Unit::TestCase
  def test_missing_pid_file_returns_opposite
    [true, false].each do |r|
      c = Conditions::ProcessRunning.new
      c.running = r
    
      c.stubs(:watch).returns(stub(:pid_file => '', :name => 'foo'))
    
      no_stdout { assert_equal !r, c.test }
    end
  end
  
  def test_not_running_returns_opposite
    [true, false].each do |r|
      c = Conditions::ProcessRunning.new
      c.running = r
    
      File.stubs(:exist?).returns(true)
      c.stubs(:watch).returns(stub(:pid_file => ''))
      File.stubs(:read).returns('5')
      System::Process.any_instance.stubs(:exists?).returns(false)
    
      assert_equal !r, c.test
    end
  end
  
  def test_running_returns_same
    [true, false].each do |r|
      c = Conditions::ProcessRunning.new
      c.running = r
    
      File.stubs(:exist?).returns(true)
      c.stubs(:watch).returns(stub(:pid_file => ''))
      File.stubs(:read).returns('5')
      System::Process.any_instance.stubs(:exists?).returns(true)
    
      assert_equal r, c.test
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
god-0.5.0 test/test_conditions_process_running.rb
god-0.6.0 test/test_conditions_process_running.rb