Sha256: 24325b773a05ee4605a9d860631e414e4c2595979c185e744572774c161bd069

Contents?: true

Size: 1.21 KB

Versions: 67

Compression:

Stored size: 1.21 KB

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_abort_on_event_condition_without_loaded_event_system
    God::EventHandler.stubs(:operational?).returns(false)
    assert_abort do
      God::EventHandler.start
      Condition.generate(:process_exits, nil).class
    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

67 entries across 67 versions & 21 rubygems

Version Path
dguettler-god-0.7.13.2 test/test_condition.rb
dguettler-god-0.7.13.3 test/test_condition.rb
dosire-god-0.7.10 test/test_condition.rb
dosire-god-0.7.12 test/test_condition.rb
dosire-god-0.7.9 test/test_condition.rb
dunedain289-god-0.7.12.1 test/test_condition.rb
dustin-god-0.7.7.1 test/test_condition.rb
eric-god-0.7.10 test/test_condition.rb
eric-god-0.7.11 test/test_condition.rb
eric-god-0.7.12 test/test_condition.rb
eric-god-0.7.14 test/test_condition.rb
eric-god-0.7.7 test/test_condition.rb
fotonauts-god-0.7.10 test/test_condition.rb
fotonauts-god-0.7.12 test/test_condition.rb
gohanlonllc-god-0.7.9 test/test_condition.rb
gordoncww-god-0.7.11.1 test/test_condition.rb
jreynolds-god-0.7.13 test/test_condition.rb
jwilkins-god-0.7.9 test/test_condition.rb
mathieuravaux-god-0.7.11 test/test_condition.rb
mojombo-god-0.7.10 test/test_condition.rb