Created
June 5, 2014 22:56
-
-
Save joelbyler/387dc4c95d562ee35d45 to your computer and use it in GitHub Desktop.
Bowling Kata starter from clerb
This file contains hidden or 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
class BowlingCalc | |
attr_reader :score | |
def initialize | |
@score = 0 | |
end | |
def roll(pins) | |
@score += pins | |
end | |
end | |
describe BowlingCalc do | |
it "adds first two rolls in first frame" do | |
calc = BowlingCalc.new | |
calc.roll 1 | |
calc.roll 4 | |
expect(calc.score).to eq(5) | |
end | |
it "adds rolls on second frame" do | |
calc = BowlingCalc.new | |
calc.roll 1 | |
calc.roll 4 | |
calc.roll 4 | |
calc.roll 5 | |
expect(calc.score).to eq(14) | |
end | |
it "can calculatae a spare" do | |
calc = BowlingCalc.new | |
calc.roll 1 | |
calc.roll 4 | |
calc.roll 4 | |
calc.roll 5 | |
calc.roll 6 | |
calc.roll 4 | |
calc.roll 5 | |
expect(calc.score).to eq(29) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment