1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
9 require 'observer_utils'
11 class TestObserverUtils < Test::Unit::TestCase
17 @object = FakeObservable.new
20 def test_simple_observer
22 @object.on(:something) { ok = true }
23 @object.fire :something
38 @object.add_observer(obs)
40 @object.notify_observers :something => 37
42 assert_equal 37, obs.arg
45 def test_multiple_observer
49 attr_reader :arg1, :arg2
55 def on_something(arg2)
60 @object.add_observer(obs)
62 @object.notify_observers :something => 2, :whatever => 1, :nothing => 3
64 assert_equal 1, obs.arg1
65 assert_equal 2, obs.arg2