-
Notifications
You must be signed in to change notification settings - Fork 492
Expand file tree
/
Copy pathscoreboard_spec.rb
More file actions
43 lines (37 loc) · 1.09 KB
/
scoreboard_spec.rb
File metadata and controls
43 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'scoreboard'
# Define a method roll(pins)
# that takes in the number of pins knocked down in a roll and adds it to the @rolls array.
RSpec.describe do
context 'player never hits a pin(20 zero scores)' do
it 'is a gutter game' do
game = Scoreboard.new
rolls = [0] * 20
rolls.each { |pins| game.roll(pins) }
expect(game.score).to eq(0)
end
end
context 'Perfect Game' do
it 'scores 300' do
game = Scoreboard.new
rolls = [10] * 12
rolls.each { |pins| game.roll(pins) }
expect(game.score).to eq(300)
end
end
context '10th frame with strike' do
it 'allows for two extra rols and adds the next two rolls as a bonus' do
game = Scoreboard.new
rolls = [0] * 18 + [10, 3, 4]
rolls.each { |pins| game.roll(pins) }
expect(game.score).to eq(17)
end
end
context '10th frame with only one strike' do
it 'one extra roll used as bonus' do
game = Scoreboard.new
rolls = [0] * 18 + [5, 5, 3]
rolls.each { |pins| game.roll(pins) }
expect(game.score).to eq(13)
end
end
end