Sha256: 680564e1b80bd5506fa4e4d34e8ccd584ab2781bfba245bd608f811176f1e5db

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require '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, :from => :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,         :from => :stomach,  :event_type => :hungry
      @head.add_handler :eat,           :from => :stomach,  :event_type => :hungry
      @head.add_handler :sip,           :from => :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

1 entries across 1 versions & 1 rubygems

Version Path
onfire-0.2.0 test/event_table_test.rb