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_file => ''))
11 assert_equal !r, c.test
15 def test_not_running_returns_opposite
16 [true, false].each do |r|
17 c = Conditions::ProcessRunning.new
20 File.stubs(:exist?).returns(true)
21 c.stubs(:watch).returns(stub(:pid_file => ''))
22 File.stubs(:read).returns('5')
23 System::Process.any_instance.stubs(:exists?).returns(false)
25 assert_equal !r, c.test
29 def test_running_returns_same
30 [true, false].each do |r|
31 c = Conditions::ProcessRunning.new
34 File.stubs(:exist?).returns(true)
35 c.stubs(:watch).returns(stub(:pid_file => ''))
36 File.stubs(:read).returns('5')
37 System::Process.any_instance.stubs(:exists?).returns(true)
39 assert_equal r, c.test