Sha256: e7d9ce8af70b8134ddbfd45066c65818f5601ef44aeae502166079f645b8f368

Contents?: true

Size: 983 Bytes

Versions: 6

Compression:

Stored size: 983 Bytes

Contents

require File.dirname(__FILE__) + '/helper'

class BadlyImplementedCondition < PollCondition
end

class TestCondition < Test::Unit::TestCase
  
  # generate
  
  def test_generate_should_return_an_object_corresponding_to_the_given_type
    assert_equal Conditions::ProcessRunning, Condition.generate(:process_running, nil).class
  end
  
  def test_generate_should_raise_on_invalid_type
    assert_raise NoSuchConditionError do
      Condition.generate(:foo, nil)
    end
  end
  
  def test_generate_should_return_a_good_error_message_for_invalid_types
    emsg = "No Condition found with the class name God::Conditions::FooBar"
    rmsg = nil
    
    begin
      Condition.generate(:foo_bar, nil)
    rescue => e
      rmsg = e.message
    end
    
    assert_equal emsg, rmsg
  end
  
  # test
  
  def test_test_should_raise_if_not_defined_in_subclass
    c = BadlyImplementedCondition.new
    
    assert_raise AbstractMethodNotOverriddenError do
      c.test
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
god-0.3.0 test/test_condition.rb
god-0.4.0 test/test_condition.rb
god-0.4.1 test/test_condition.rb
god-0.4.3 test/test_condition.rb
god-0.5.0 test/test_condition.rb
god-0.6.0 test/test_condition.rb