Skip to content

Instantly share code, notes, and snippets.

@jon-acker
Created September 15, 2019 15:15
Show Gist options
  • Save jon-acker/0d40e0632377c547e343036aec60ea99 to your computer and use it in GitHub Desktop.
Save jon-acker/0d40e0632377c547e343036aec60ea99 to your computer and use it in GitHub Desktop.
Tic Tac Toe

Rules

  • A game starts with an empty 3x3 grid
  • Two players, one plays symbol X the other plays symbol O
  • player can place symbol in any square that's not taken
  • If player tried to place symbol in already taken squares, they are told "cannot play that position"
  • When all 9 squares are full - the game is over and ends with tie
  • The first player to have 3 of their symbols in a diagonal, row or column wins
    Scenario: Placing a symbol in square that is free
        Given the square 1,1 is free
        When player X plays the square 1,1
        Then the grid should have an X in square 1,1
      
    Scenario: Being told cannot place symbol in already taken square
        Given the square 1,1 has already been taken
        When player X plays the square 1,1
        Then player should be told "square has already been taken"
    
    Scenario: Being told the same symbol cannot be played twice
        Given player X has just played
        When a player tries to play an X
        Then the player should be told "same symbol cannot be played twice"

  Scenario: Player X wins when they have 3 in a diagonal
    Given the following moves have been played:
      | Player | Square |
      | X      | 1,1    |
      | O      | 1,2    |
      | X      | 2,2    |
      | O      | 2,3    |
    When player plays an X in square 1,3
    Then player X should have won
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment