Implement notification.
[kaya/ydirson.git] / test / test_controller.rb
blob32587d9def705fc4a7606024f44d7a1c6ddd4c27
1 require 'test/unit'
2 require 'controller'
4 class TestController < Test::Unit::TestCase
5   def setup
6     @board = mock('board')
7     class << @board
8       include Observable
9     end
10     @history = mock('history')
11     @controller = Controller.new(@board, @history)
12   end
13   
14   def test_on_new_move
15     @history.expects(:add_move).once.with('state', 'move')
16     @board.changed
17     @board.notify_observers :new_move => { :state => 'state', :move => 'move' }
18   end
19   
20   def test_back
21     @history.expects(:back).returns(['state', 'move'])
22     @board.expects(:back).with('state', 'move')
23     @controller.on_back
24   end
25   
26   def test_forward
27     @history.expects(:forward).returns(['state', 'move'])
28     @board.expects(:forward).with('state', 'move')
29     @controller.on_forward
30   end
31 end