Sha256: 3b2406aeb46ec0ad2b0e9c04fb57d0f55e2568943eba3325297e2cd2f5d661f0

Contents?: true

Size: 1.25 KB

Versions: 70

Compression:

Stored size: 1.25 KB

Contents

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

class TestTrigger < Test::Unit::TestCase
  def setup
    Trigger.reset
  end
  
  # base case
  
  def test_should_have_empty_triggers
    assert_equal({}, Trigger.triggers)
  end
  
  # register
  
  def test_register_should_add_condition_to_triggers
    c = Condition.new
    c.watch = stub(:name => 'foo')
    Trigger.register(c)
    
    assert_equal({'foo' => [c]}, Trigger.triggers)
  end
  
  def test_register_should_add_condition_to_triggers_twice
    watch = stub(:name => 'foo')
    c = Condition.new
    c.watch = watch
    Trigger.register(c)
    
    c2 = Condition.new
    c2.watch = watch
    Trigger.register(c2)
    
    assert_equal({'foo' => [c, c2]}, Trigger.triggers)
  end
  
  # deregister
  
  def test_deregister_should_remove_condition_from_triggers
    c = Condition.new
    c.watch = stub(:name => 'foo')
    Trigger.register(c)
    Trigger.deregister(c)
    
    assert_equal({}, Trigger.triggers)
  end
  
  # broadcast
  
  def test_broadcast_should_call_process_on_each_condition
    c = Condition.new
    c.watch = stub(:name => 'foo')
    Trigger.register(c)
    
    c.expects(:process).with(:state_change, [:up, :start])
    
    Trigger.broadcast(c.watch, :state_change, [:up, :start])
  end
end

Version data entries

70 entries across 70 versions & 22 rubygems

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