Giter VIP home page Giter VIP logo

tic-tac-toe's Introduction

Tic Tac Toe

This is a learning situation, to demonstrate your capabilities regarding testing.

Setup

Fork and clone the repository. There is a Gemfile, so install the dependencies with bundle install. The only dependencies are rspec and byebug.

Scenario

You have just taken over a legacy implementation of the game "Tic Tac Toe" that the previous developer never finished. There is an example program that "drives" part of the game, so you can at least see how the game's Board works.

Run it:

ruby lib/driver.rb

You should see the output that describes the results after a couple of 'x' and 'o' turns. Feel free to take a look at lib/driver.rb and modify it.

What to do

Run the test suite.

rspec

You should see a handful of failing tests.

Step 1

Here you are given the tests for a Game class, and should try to implement the Game class such that it passes the tests.

Read the tests in spec/game_spec.rb.

Take a look at the first test that is failing, and fix the implementation in game.rb to get the test to pass.

You goal is to complete the implementation of the Game class. Don't modify the file spec/game_spec.rb. If you get stuck, switch to Step 2.

Step 2

here you are given an implementation of a Board, and should try to cover the class with tests.

Read the implementation of the Board class in lib/board.rb.

In spec/board_spec.rb, test each method of the Board class. You can skip to_s. Don't modify the file lib/board.rb.

Think about how to test. If you only have one test for each method, you've missed something.

Focus on behavior, not implementation.

Step 3

Complete the implementation of Game, driven by tests, and complete the tests of Board, given the implementation. If you have questions about the features, just ask.

Step 4

Once your test suite is passing, rerun the driver program:

ruby lib/driver.rb

And verify the output is what you expect.

Step 4

Refactor the test suite and/or implementations. There are a couple opportunities to improve the test suite, or refactor the implementations in Board, and demonstrate your understanding of writing a maintainable test suite. Be sure that the suite stays green.

Step 5

Create a pull request.

Extra Challenges

Now that you are green, and "shamelessly" so, look at the Game winner method. Investigate how you can make this better through object-oriented techniques. Is there a way to remove that big conditional statement? Perhaps the Board class, or a new class, might help.

(c) 2020 Yong Bakos. All rights reserved.

tic-tac-toe's People

Contributors

mtornatta avatar ybakos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.