diff options
| author | Teddy Wing | 2015-04-14 17:57:55 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2015-04-14 17:57:55 -0400 | 
| commit | e6910571b4bb9f65a241df9ff28ff4cfbb832aa5 (patch) | |
| tree | 1762dbea5cb9854c7e481b04cd45426222d1721a | |
| parent | 231060de4c493a9c6ba3510a9be4d405517af5c6 (diff) | |
| download | tic-tac-toe-e6910571b4bb9f65a241df9ff28ff4cfbb832aa5.tar.bz2 | |
Player: Add `initialize` method, use insignia constants
Add an `initialize` method to get rid of our test errors and use the
constants we created in 231060de4c493a9c6ba3510a9be4d405517af5c6 when
creating new `Player`s.
| -rw-r--r-- | main.rb | 4 | ||||
| -rw-r--r-- | player.rb | 5 | ||||
| -rw-r--r-- | spec/player_spec.rb | 2 | 
3 files changed, 8 insertions, 3 deletions
| @@ -2,8 +2,8 @@ require_relative 'board'  require_relative 'player'  board = Board.new -player_1 = Player.new('X', board) -player_2 = Player.new('O', board) +player_1 = Player.new(Player::INSIGNIAS[:x], board) +player_2 = Player.new(Player::INSIGNIAS[:o], board)  board.current_player = player_1  until board.winner @@ -3,4 +3,9 @@ class Player      :x => 'X',      :o => 'O'    } +   +  def initialize(insignia, board) +    @insignia = insignia +    @board = board +  end  end diff --git a/spec/player_spec.rb b/spec/player_spec.rb index 3306095..4dee7e7 100644 --- a/spec/player_spec.rb +++ b/spec/player_spec.rb @@ -16,7 +16,7 @@ describe Player do    describe '#move' do      before do        board = Board.new -      @player = Player.new('X', board) +      @player = Player.new(Player::INSIGNIAS[:x], board)      end      it 'raises an ArgumentError given invalid coordinates' do | 
