learn-co-curriculum / oo-tic-tac-toe

Other
4 stars 641 forks source link

Test Consistency #17

Closed kirangp closed 8 years ago

kirangp commented 8 years ago

Hi, In some of the tests the positions in the board are 1-9 & in another test case it uses 0-8. Please use a consistent 1-9 approach in tests. I have added the test cases below. Thanks

Example describe '#move' do it 'allows "X" player in the top left and "O" in the middle' do game = TicTacToe.new game.move(1, "X") game.move(5, "O")

    board = game.instance_variable_get(:@board)

    expect(board).to eq(["X", " ", " ", " ", "O", " ", " ", " ", " "])
  end
end

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
mendelB commented 8 years ago

Hey @kirangp I think the idea is that some methods deal with user input and thus use a 1-9 argument and some are more 'internal' and take a 0-8 argument. So the specs test accordingly. We are looking into perhaps a more consistent approach across the Tic-Tac-Toe labs. and I'll update the README to stress this in the appropriate methods. I'm going to close this issue. Thanks so much for the submission!!