Sha256: 2f7a8153c767a3c157e2accb51cc3ca89b11303f432fac7176a8d52159a55075

Contents?: true

Size: 672 Bytes

Versions: 13

Compression:

Stored size: 672 Bytes

Contents

# -*- coding: utf-8 -*-


require_relative 'helper'


class TestInvoker < Test::Unit::TestCase

  class Invoker
    include Xot::Invoker
  end

  def invoker(*args, &block)
    Invoker.new(*args, &block)
  end

  def handler(method, &block)
    o = Object.new
    o.define_singleton_method method, &block
    o
  end

  def test_add_handler()
    inv, var = invoker, nil

    assert_equal nil, var

    h = handler(:test) {|e| var = e.var}
    inv.add_handler h
    inv.invoke :test, var: 1
    assert_equal 1, var

    inv.invoke :test, var: 2
    assert_equal 2, var

    inv.remove_handler h
    inv.invoke :test, var: 3
    assert_equal 2, var
  end

end# TestInvoker

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
xot-0.1.34 test/test_invoker.rb
xot-0.1.33 test/test_invoker.rb
xot-0.1.32 test/test_invoker.rb
xot-0.1.31 test/test_invoker.rb
xot-0.1.30 test/test_invoker.rb
xot-0.1.29 test/test_invoker.rb
xot-0.1.28 test/test_invoker.rb
xot-0.1.27 test/test_invoker.rb
xot-0.1.26 test/test_invoker.rb
xot-0.1.25 test/test_invoker.rb
xot-0.1.24 test/test_invoker.rb
xot-0.1.23 test/test_invoker.rb
xot-0.1.22 test/test_invoker.rb