This exercise is inspired by a Ruby exercise of the same name written by James Nolan "Jim" Weirich. The focus of this kata however is on using both BDD and TDD when developing the solution.
This repository is primarily intended for the participants of my Test-Driven Tuesday workshop at Thomson Reuters.
The game should work like this. The program starts by telling the user to think of an animal. It then begins asking a series of yes/no questions about that animal: does it swim, does it have hair, etc. Eventually, it will narrow down the possibilities to a single animal and guess that (Is it a kitten?).
If the program has guessed correctly, the game is over and may be restarted with a new animal. If the program has guess incorrectly, it asks the user for the kind of animal they were thinking of and then asks for the user to provide a question that can distinguish between its incorrect guess and the correct answer. It then adds the new question and animal to its "database" and will guess that animal in the future (if appropriate).
$> ./bin/animal-quiz
Think of an animal and I'll try to guess it. Ready?
> y
Is it a kitten?
> n
You win! Help me learn from my mistake before you go. What animal were you thinking of?
> a rabbit
What question would help me distinguish a rabbit from a kitten?
> Is it a small animal?
For a rabbit, what is the answer to your question?
> y
Thanks. Play again?
> y
Think of an animal and I'll try to guess it. Ready?
> y
Is it a small animal?
> y
Is it a rabbit?
> n
You win! Help me learn from my mistake before you go. What animal were you thinking of?
> a Shih Tzu
What question would help me distinguish a rabbit from a Shih Tzu?
> Is it a kind of dog?
For a Shih Tzu, what is the answer to your question?
> y
Thanks. Play again?
> y
Think of an animal and I'll try to guess it. Ready?
> y
Is it a small animal?
> y
Is it a kind of dog?
> y
Is it a Shih Tzu?
> y
I knew it! Play again?
> n
- the quiz:
./bin/animal-quiz
ornode bin/animal-quiz
- the 'local build' (jshint, unit and acceptance tests):
grunt test
- acceptance tests only:
grunt test:behaviour
- unit tests only:
grunt test:spec
- Features:
- scenarios: /features
- acceptance testing framework: /features/lib
- steps: /features/steps
- runner: /test/features.js
- Unit tests: /test/spec
- Application: /src
- A primer on user stories by Antony Marcano - It starts with a story
- Test doubles in JavaScript by Jan Molak - Mocking JavaScript a little - test doubles with sinon.js, mocha and chai
- Original Ruby Quiz
- Potentially helpful data structure: Binary Tree
- Node CLI by Fil Maj and Michael Brooks: Master the CLI with Node
- Setting up node in IntelliJ/WebStorm