1 require File.dirname(__FILE__) + '/helper'
3 class TestConditionsProcessRunning < Test::Unit::TestCase
4 def test_missing_pid_file_returns_opposite
5 [true, false].each do |r|
6 c = Conditions::ProcessRunning.new
9 c.stubs(:watch).returns(stub(:pid => 123, :name => 'foo'))
12 assert_equal !r, c.test
17 def test_not_running_returns_opposite
18 [true, false].each do |r|
19 c = Conditions::ProcessRunning.new
22 File.stubs(:exist?).returns(true)
23 c.stubs(:watch).returns(stub(:pid => 123))
24 File.stubs(:read).returns('5')
25 System::Process.any_instance.stubs(:exists?).returns(false)
27 assert_equal !r, c.test
31 def test_running_returns_same
32 [true, false].each do |r|
33 c = Conditions::ProcessRunning.new
36 File.stubs(:exist?).returns(true)
37 c.stubs(:watch).returns(stub(:pid => 123))
38 File.stubs(:read).returns('5')
39 System::Process.any_instance.stubs(:exists?).returns(true)
41 assert_equal r, c.test