Skip to content

Commit

Permalink
Added Game#over? method
Browse files Browse the repository at this point in the history
  • Loading branch information
lisahamm committed Mar 12, 2015
1 parent 5309b1d commit dc90ff3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tic_tac_toe/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def in_progress?
!winner? && !tie?
end

def over?
board.over?
end

def winner?
board.winner?
end
Expand Down
6 changes: 6 additions & 0 deletions spec/board_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module TicTacToe
board.set_cell(1, 'X')
expect(board.get_cell(1)).to eq 'X'
end

it "can remove a cell value" do
board.set_cell(1, 'X')
board.remove_mark(1)
expect(board.get_cell(1)).to eq nil
end
end

describe "#empty_cell?" do
Expand Down
14 changes: 14 additions & 0 deletions spec/game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ module TicTacToe
end
end

describe "#over?" do
it "is false when in play" do
expect(game_in_play.over?).to eq false
end

it "is true when won" do
expect(won_game.over?).to eq true
end

it "is true when tied" do
expect(tie_game.over?).to eq true
end
end

describe "#winner?" do
it "is false when in play" do
expect(game_in_play.winner?).to eq false
Expand Down

0 comments on commit dc90ff3

Please sign in to comment.