-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbowling_spec.rb
59 lines (45 loc) · 1.53 KB
/
bowling_spec.rb
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require_relative 'bowling'
class BowlingSpecs
describe Bowling do
before(:each) do
@bowling = Bowling.new
end
it 'scores 0 for a gutterball' do
score = @bowling.score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score.should eq 0
end
it 'scores 10 for a strike' do
score = @bowling.score [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score.should eq 10
end
it 'scores 20 for a game of all 1s' do
score = @bowling.score [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
score.should eq 20
end
it 'scores 20 for a spare then a 5' do
rolls = [7,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score = @bowling.score(rolls)
score.should eq 20
end
it 'scores 24 for a strike followed by a 4 and a 3' do
score = @bowling.score [10,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score.should eq 24
end
it 'scores 30 for two strikes in a row' do
score = @bowling.score [10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score.should eq 30
end
it 'scores 60 for three strikes in a row' do
score = @bowling.score [10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score.should eq 60
end
it 'scores 270 when you miss the last two shots ' do
score = @bowling.score [10,10,10,10,10,10,10,10,10,10,0,0]
score.should eq 270
end
it 'scores 300 for a perfect game' do
score = @bowling.score [10,10,10,10,10,10,10,10,10,10,10,10]
score.should eq 300
end
end
end