Coder Social home page Coder Social logo

animal-quiz's Introduction

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

animal-quiz's People

Contributors

awashbrook avatar jan-molak avatar manjbhachu avatar mortonfox avatar

Watchers

 avatar  avatar  avatar

animal-quiz's Issues

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.