I have been working on a Connect 4 game with a friend. We are doing this for the Odin Project’s testing section. The game works, but I cannot get the tests to pass.
Note: This is solved, see the comment.
Below is an image of the board:
If a player drops 4 tokens in a row, that player wins:
My code is working fine, but when I run tests on the method which checks for a win, the tests fail.
The relevant tests are:
The first of these tests passes fine, because the starting value of game.won? is false. In order to break out of the game loop, game.won? is changed to true:
But I can’t get the tests to pass for the life of me. I’ve tried
expect(game.won?).to be_truthy, and still nothing works. I put the
analyze_board function into its own module, and added the question at the end asking if you want to start a new game, so the game doesn’t exit immediately. Still no luck!
The code is on my github if anyone wants to take a look.