This is a learning situation, to demonstrate your capabilities regarding testing.
Fork and clone the repository. There is a Gemfile, so install the dependencies
with bundle install
. The only dependency is rspec.
You have just taken over a legacy implementation of a "game" that the previous developer never finished. There is an example program that "drives" the game, so you can see the issues. Run it:
ruby lib/driver.rb
You should see the output of a variety of game combinations, only one of which is valid. Feel free to take a look at lib/driver.rb.
Run the test suite.
rspec
You should see a handful of skipped tests and one failing test.
Read the tests in spec/game_spec.rb.
Take a look at which test is failing, and fix the implementation in game.rb to get the test to pass.
Complete the remaining features, driven by tests. Perform a TDD workflow, replacing each "skip" with valid tests for each game scenario. If you have questions about the features, just ask.
Once your test suite is passing, rerun the driver program:
ruby lib/driver.rb
And verify the output is what you expect.
Refactor the test suite. There are a couple opportunities to improve the test suite, and demonstrate your understanding of writing a maintainable test suite. Be sure that the suite stays green.
Create a pull request.
(c) 2018 Yong Bakos. All rights reserved.