Giter VIP home page Giter VIP logo

black-jack-challenge's Introduction

Black Jack Unit Testing

When playing cards at the casino accuracy is of extreme importance. One number off could be the matter of thousands or millions of dollars lost. For this exercise we are going to write unit tests for the method that calculates the total of a hand in blackjack. Writing tests allow you to make sure the behavior you expect to happen is actually happening. They also give you direction in the design process of your code.

The testing framework we will be using for this exercise is RSpec. RSpec is a DSL (Domain Specific Language) that makes writing tests easier and more semantic. It is heavily used in the Rails community.

The RSpec documentation is a great place to start learning what methods are available to you when writing tests. Look through rspec-core and rspec-expectations. Avoid the rspec-mocks and rspec-rails sections for now.

There is already a Deck class set up with some tests. Take a few minutes to read through those tests to figure out what is going on. Once you have a better idea of whats happening see if you can start writing the tests for the #calculate_hand method in the Hand class. Finally, implement the actual method in order to make the tests pass.

To run the tests you will type: rspec spec into your terminal.

Note: Make sure to run bundle install to get RSpec installed

Extra Credit: For an extra challenge make it so that the #calculate_hand method takes into account Aces values of either 1 or 11.

black-jack-challenge's People

Contributors

spencercdixon avatar

Watchers

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