Sha256: a31156dac44a261851ebb2a6dc7f49f7a412f19954245791fb1f24e5c7b7ba5f

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 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 => ''))
    
      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

4 entries across 4 versions & 1 rubygems

Version Path
god-0.3.0 test/test_conditions_process_running.rb
god-0.4.0 test/test_conditions_process_running.rb
god-0.4.1 test/test_conditions_process_running.rb
god-0.4.3 test/test_conditions_process_running.rb