Skip to content

One of the exercises for the participants of my "Test-Driven Tuesday" workshops

Notifications You must be signed in to change notification settings

jan-molak/animal-quiz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Animal Quiz

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.

Build Status

The goal

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).

Example run

$> ./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 ATDD Cycle

ATDD Cycle

Running:

  • the quiz: ./bin/animal-quiz or node 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

What's where?

Manuals

  • Yadda, the bdd tests framework
  • Mocha, the test runner
  • Chai, the assertion library

Useful materials

About

One of the exercises for the participants of my "Test-Driven Tuesday" workshops

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published