Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests using Rspec, and pdf file with Kata presentation
- Loading branch information
1 parent
1b15db7
commit 23b9ee0
Showing
5 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require 'spec_helper' | ||
|
||
describe BowlingGame do | ||
|
||
before(:each) do | ||
@game = BowlingGame.new | ||
end | ||
|
||
it "should calculate a gutter game" do | ||
roll_many(20, 0) | ||
@game.score.should == 0 | ||
end | ||
|
||
it "should calculate an all ones game" do | ||
roll_many(20, 1) | ||
@game.score.should == 20 | ||
end | ||
|
||
it "should calculate a spare" do | ||
roll_spare | ||
@game.roll(3) | ||
roll_many(17, 0) | ||
@game.score.should == 16 | ||
end | ||
|
||
it "should calculate a strike" do | ||
roll_strike | ||
@game.roll(3) | ||
@game.roll(4) | ||
roll_many(16,0) | ||
@game.score.should == 24 | ||
end | ||
|
||
it "should calculate a perfect game" do | ||
12.times { roll_strike } | ||
@game.score.should == 300 | ||
end | ||
|
||
private | ||
|
||
def roll_many(n, pins) | ||
n.times { @game.roll(pins) } | ||
end | ||
|
||
def roll_spare | ||
@game.roll(5) | ||
@game.roll(5) | ||
end | ||
|
||
def roll_strike | ||
@game.roll(10) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rubygems' | ||
require 'spec' | ||
|
||
require 'bowling_game' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require 'rubygems' | ||
require 'test/unit' | ||
|
||
require File.expand_path('../../lib/bowling_game', __FILE__) | ||
require 'bowling_game' |