Ok maybe I'm confused but the spec is using "position" as integers for some checks, strings for other checks, is sometimes based on 0..8 and other times 1..9. What is going on here?
eg: see below
describe '#position_taken?' do
it 'returns true/false based on position in board' do
game = TicTacToe.new
board = ["X", " ", " ", " ", " ", " ", " ", " ", "O"]
game.instance_variable_set(:@board, board)
position = 0
expect(game.position_taken?(position)).to be(true)
position = 8
expect(game.position_taken?(position)).to be(true)
position = 1
expect(game.position_taken?(position)).to be(false)
position = 7
expect(game.position_taken?(position)).to be(false)
end
end
describe '#valid_move?' do
it 'returns true/false based on position' do
game = TicTacToe.new
board = [" ", " ", " ", " ", "X", " ", " ", " ", " "]
game.instance_variable_set(:@board, board)
position = "1"
expect(game.valid_move?(position)).to be_truthy
position = "5"
expect(game.valid_move?(position)).to be_falsey
position = "invalid"
expect(game.valid_move?(position)).to be_falsey
end
end
Ok maybe I'm confused but the spec is using "position" as integers for some checks, strings for other checks, is sometimes based on 0..8 and other times 1..9. What is going on here? eg: see below describe '#position_taken?' do it 'returns true/false based on position in board' do game = TicTacToe.new board = ["X", " ", " ", " ", " ", " ", " ", " ", "O"] game.instance_variable_set(:@board, board)