more diagnostics
[god.git] / test / test_condition.rb
blob92c70efd2808f8a60821281c71a5c835afa70b7b
1 require File.dirname(__FILE__) + '/helper'
3 class BadlyImplementedCondition < PollCondition
4 end
6 class TestCondition < Test::Unit::TestCase
7   
8   # generate
9   
10   def test_generate_should_return_an_object_corresponding_to_the_given_type
11     assert_equal Conditions::ProcessRunning, Condition.generate(:process_running, nil).class
12   end
13   
14   def test_generate_should_raise_on_invalid_type
15     assert_raise NoSuchConditionError do
16       Condition.generate(:foo, nil)
17     end
18   end
19   
20   def test_generate_should_return_a_good_error_message_for_invalid_types
21     emsg = "No Condition found with the class name God::Conditions::FooBar"
22     rmsg = nil
23     
24     begin
25       Condition.generate(:foo_bar, nil)
26     rescue => e
27       rmsg = e.message
28     end
29     
30     assert_equal emsg, rmsg
31   end
32   
33   # test
34   
35   def test_test_should_raise_if_not_defined_in_subclass
36     c = BadlyImplementedCondition.new
37     
38     assert_raise AbstractMethodNotOverriddenError do
39       c.test
40     end
41   end
42 end