Sha256: b4aa143a1c549df36e2221af850857493f11a8b79dd00ad4f3124c451a3a1890

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require 'test_helper'

class EventHandlerTest < MiniTest::Spec
  include Apotomo::TestCaseMethods::TestController

  describe "EventHandler" do
    before do
      @mum = mouse
        @mum << mouse_mock(:kid)
    end

    it "respond to #process_event" do
      h = Apotomo::EventHandler.new
      e = Apotomo::Event.new(:squeak, @mum)
      assert_equal nil, h.process_event(e)
    end

    it "respond to #call and push #process_events' results ordered to root's #page_updates" do
      [@mum, @mum[:kid], @mum].each_with_index do |source, i|
        e = Apotomo::Event.new(:squeak, source)
        h = Apotomo::EventHandler.new
        h.stub :process_event, "tick#{i}" do
          h.call(e)
        end
      end

      assert_equal 3, @mum.page_updates.size
      assert_equal "tick0", @mum.page_updates[0]
      assert_equal "tick1", @mum.page_updates[1]
      assert_equal "tick2", @mum.page_updates[2]
      assert_equal 0, @mum[:kid].page_updates.size
    end

    #TODO: handler expect #process_event
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apotomo-1.3.2 test/event_handler_test.rb
apotomo-1.3.1 test/event_handler_test.rb
apotomo-1.3.0 test/event_handler_test.rb
apotomo-1.2.6 test/event_handler_test.rb