KillerDesigner
10/6/2013 - 5:49 AM

bowling_spec.rb

require './bowling'

describe Bowling do
  describe '#score' do

		let(:game) { Bowling.new }

		it 'should start at 0' do
			game.score.should == 0
		end

		it 'should be 300 for a perfect score' do
			12.times{ game.roll(10) }
			game.score.should == 300
		end

		it 'should be 5 if my first roll is a 5' do
			game.roll(5)
			game.score.should == 5
		end

		it 'shoud be 10 if my first frame is a spare' do
			2.times { game.roll(5) }
			game.score.should == 10
		end

		it 'should be 20 if I roll three fives to start' do
			3.times { game.roll(5) }
			game.score.should == 20
		end

		it 'should be 28 if I roll 10, 5, 4 to start' do
			game.roll(10)
			game.roll(5)
			game.roll(4)
			game.score.should == 28
		end

		it 'should throw an error if you hit more than 10 pins in a frame' do
			expect {
				game.roll(7)
				game.roll(7)
			}.to raise_exception(CheaterException)
		end
	end
end