3 class TestWatch < Test::Unit::TestCase
8 def test_should_have_empty_start_conditions
9 assert_equal [], @watch.conditions[:start]
12 def test_should_have_empty_restart_conditions
13 assert_equal [], @watch.conditions[:restart]
16 def test_should_have_standard_attributes
17 assert_nothing_raised do
20 @watch.start = 'start'
22 @watch.restart = 'restart'
29 def test_start_if_should_modify_action_within_scope
30 assert_equal nil, @watch.instance_variable_get(:@action)
31 @watch.start_if do |w|
32 assert_equal :start, @watch.instance_variable_get(:@action)
34 assert_equal nil, @watch.instance_variable_get(:@action)
37 def test_restart_if_should_modify_action_within_scope
38 assert_equal nil, @watch.instance_variable_get(:@action)
39 @watch.restart_if do |w|
40 assert_equal :restart, @watch.instance_variable_get(:@action)
42 assert_equal nil, @watch.instance_variable_get(:@action)
47 def test_condition_should_record_condition_in_correct_list
49 @watch.start_if do |w|
50 w.condition(:fake_condition) { |c| cond = c }
52 assert_equal 1, @watch.conditions[:start].size
53 assert_equal cond, @watch.conditions[:start].first
56 def test_condition_should_record_condition_in_correct_list
58 @watch.restart_if do |w|
59 w.condition(:fake_condition) { |c| cond = c }
61 assert_equal 1, @watch.conditions[:restart].size
62 assert_equal cond, @watch.conditions[:restart].first
65 def test_condition_called_from_outside_if_block_should_raise
66 assert_raise ExitCalledError do
67 @watch.condition(:fake_condition) { |c| cond = c }
71 def test_condition_should_be_block_optional
72 @watch.start_if do |w|
75 assert_equal 1, @watch.conditions[:start].size