Sha256: 1ed1118550d01371dc5b0c8f6fcb540746f693c242024043fb18fbfbf700eb2a

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'minitest/autorun'
require 'webgen/blackboard'

class TestBlackboard < MiniTest::Unit::TestCase

  def setup
    @blackboard = Webgen::Blackboard.new
  end

  def test_add_listener
    assert_raises(ArgumentError) { @blackboard.add_listener(:test) }
    @blackboard.add_listener([:test, :other]) { throw :called }
    assert_throws(:called) { @blackboard.dispatch_msg(:test) }
    assert_throws(:called) { @blackboard.dispatch_msg(:other) }
  end

  def test_remove_listener
    @blackboard.add_listener(:test, 'id') { throw :called }
    assert_throws(:called) { @blackboard.dispatch_msg(:test) }
    @blackboard.remove_listener(:test, 'id')
    @blackboard.dispatch_msg(:test)
  end

  def test_dispatch_msg
    @blackboard.add_listener(:test) { throw :called }
    assert_throws(:called) { @blackboard.dispatch_msg(:test) }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webgen-1.0.0.beta3 test/webgen/test_blackboard.rb
webgen-1.0.0.beta2 test/webgen/test_blackboard.rb
webgen-1.0.0.beta1 test/webgen/test_blackboard.rb