Sha256: e0a76bbc562a6c5b834a14094dc0c960ccf1285c712bebd08ea80e065d70c655

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

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

class EventTableTest < Test::Unit::TestCase

  context "An EventTable" do
    setup do
      @head = Onfire::EventTable.new
    end
    
    should "return an empty array when it can't find handlers" do
      @head.add_handler :drink, :source_name => :stomach, :event_type => :thirsty
      
      assert_equal [], @head.handlers_for(    :hungry, :stomach)
      assert_equal [], @head.all_handlers_for(:hungry, :stomach)
    end
    
    should "return handlers in the same order as they were added" do
      @head.add_handler :drink,         :source_name => :stomach, :event_type => :hungry
      @head.add_handler :eat,           :source_name => :stomach, :event_type => :hungry
      @head.add_handler :sip,           :source_name => :mouth,   :event_type => :dry
      @head.add_handler :have_desert,                             :event_type => :hungry
      
      assert_equal [:sip], @head.handlers_for(:dry, :mouth)
      assert_equal [:sip], @head.all_handlers_for(:dry, :mouth)
      
      assert_equal [:drink, :eat], @head.handlers_for(:hungry, :stomach)
      assert_equal [:drink, :eat, :have_desert], @head.all_handlers_for(:hungry, :stomach)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
nilclass-onfire-0.1.3.nc test/event_table_test.rb
nilclass-onfire-0.1.2.nc test/event_table_test.rb
nilclass-onfire-0.1.1.nc test/event_table_test.rb
onfire-0.1.0 test/event_table_test.rb