Sha256: ca23ab052031dbeb31ca398af2903b5c23e6c6e176efd115d677a6c02f23d86e

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

# :nodoc: all

require "test/unit"
require "n/events"

class TC_Events < Test::Unit::TestCase
	# :nodoc: all
	include N
	
	def setup
		$flag = 0
		$flag2 = 1
		@events = N::EventManager.new
	end

	def teardown
		@events = nil
	end

	def test_events
		@events.add_handler("my.event", "test1", proc { |val|
			$flag = val
		})
		@events.add_handler("my.event", "test2", proc { |val|
			$flag2 += val
		})

		@events.fire("my.event", 5)

		assert_equal(5, $flag)
		assert_equal(6, $flag2)

		@events.fire("my.event", 5)

		assert_equal(11, $flag2)

		# test remove handler

		@events.remove_handler("my.event", "test2")
		@events.fire("my.event", 5)

		assert_equal(11, $flag2)
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.2.0 test/n/tc_events.rb
nitro-0.3.0 test/n/tc_events.rb