Skip to content

Instantly share code, notes, and snippets.

@joelbyler
Created June 5, 2014 22:56
Show Gist options
  • Save joelbyler/387dc4c95d562ee35d45 to your computer and use it in GitHub Desktop.
Save joelbyler/387dc4c95d562ee35d45 to your computer and use it in GitHub Desktop.
Bowling Kata starter from clerb
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