icu_tournament 1.9.3 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +5 -1
- data/lib/icu_tournament/player.rb +1 -2
- data/lib/icu_tournament/result.rb +2 -2
- data/lib/icu_tournament/tournament.rb +38 -0
- data/lib/icu_tournament/tournament_fcsv.rb +1 -1
- data/lib/icu_tournament/tournament_krause.rb +19 -8
- data/lib/icu_tournament/util.rb +4 -4
- data/lib/icu_tournament/version.rb +1 -1
- data/spec/player_spec.rb +118 -120
- data/spec/result_spec.rb +66 -66
- data/spec/team_spec.rb +16 -16
- data/spec/tie_break_spec.rb +51 -51
- data/spec/tournament_fcsv_spec.rb +94 -94
- data/spec/tournament_krause_spec.rb +170 -151
- data/spec/tournament_sp_spec.rb +89 -89
- data/spec/tournament_spec.rb +323 -276
- data/spec/tournament_spx_spec.rb +95 -95
- data/spec/util_spec.rb +127 -127
- metadata +59 -77
data/spec/result_spec.rb
CHANGED
@@ -5,137 +5,137 @@ module ICU
|
|
5
5
|
describe Result do
|
6
6
|
context "a typical result" do
|
7
7
|
it "should have a round, player number and score plus optional opponent number, colour and rateable flag" do
|
8
|
-
|
8
|
+
expect { Result.new(3, 5, 'W', :opponent => 11, :colour => 'W') }.not_to raise_error
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context "round number" do
|
13
13
|
it "should be a positive integer" do
|
14
|
-
|
15
|
-
|
16
|
-
Result.new(1, 2, 0).round.
|
17
|
-
Result.new(' 3 ', 2, 0).round.
|
14
|
+
expect { Result.new(-2, 2, 0) }.to raise_error(/invalid positive integer/)
|
15
|
+
expect { Result.new(0, 2, 0) }.to raise_error(/invalid positive integer/)
|
16
|
+
expect(Result.new(1, 2, 0).round).to eq(1)
|
17
|
+
expect(Result.new(' 3 ', 2, 0).round).to eq(3)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
context "player number" do
|
22
22
|
it "should be an integer" do
|
23
|
-
|
24
|
-
Result.new(1, 2, 0).player.
|
25
|
-
Result.new(1, ' 0 ', 0).player.
|
26
|
-
Result.new(1, -5, 0).player.
|
27
|
-
Result.new(1, " 9 ", 0).player.
|
23
|
+
expect { Result.new(1, ' ', 0) }.to raise_error(/invalid integer/)
|
24
|
+
expect(Result.new(1, 2, 0).player).to eq(2)
|
25
|
+
expect(Result.new(1, ' 0 ', 0).player).to eq(0)
|
26
|
+
expect(Result.new(1, -5, 0).player).to eq(-5)
|
27
|
+
expect(Result.new(1, " 9 ", 0).player).to eq(9)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
context "score" do
|
32
32
|
[1, 1.0, 'W', 'w', '+'].each do |score|
|
33
33
|
it "should be 'W' for #{score}, #{score.class}" do
|
34
|
-
Result.new(1, 2, score).score.
|
34
|
+
expect(Result.new(1, 2, score).score).to eq('W')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
[0, 0.0, 'L', 'l', '-'].each do |score|
|
38
38
|
it "should be 'L' for #{score}, #{score.class}" do
|
39
|
-
Result.new(1, 2, score).score.
|
39
|
+
expect(Result.new(1, 2, score).score).to eq('L')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
['½', 0.5, 'D', 'd', '='].each do |score|
|
43
43
|
it "should be 'L' for #{score}, #{score.class}" do
|
44
|
-
Result.new(1, 2, score).score.
|
44
|
+
expect(Result.new(1, 2, score).score).to eq('D')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
['', ' ', 'x', 2, -1.0, nil].each do |score|
|
48
48
|
it "should raise error for invalid score (#{score})" do
|
49
|
-
|
49
|
+
expect { Result.new(1, 2, score) }.to raise_error(/invalid score/)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
it "should be expressable as a number" do
|
53
|
-
Result.new(1, 2, 'W').points.
|
54
|
-
Result.new(1, 2, 'L').points.
|
55
|
-
Result.new(1, 2, 'D').points.
|
53
|
+
expect(Result.new(1, 2, 'W').points).to eq(1.0)
|
54
|
+
expect(Result.new(1, 2, 'L').points).to eq(0.0)
|
55
|
+
expect(Result.new(1, 2, 'D').points).to eq(0.5)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
context "colour" do
|
60
60
|
it "should be 'W' or 'B' or nil (unknown)" do
|
61
|
-
Result.new(4, 1, 0).colour.
|
62
|
-
Result.new(4, 1, 0, :colour => 'W').colour.
|
63
|
-
Result.new(4, 1, 0, :colour => 'white').colour.
|
64
|
-
Result.new(4, 1, 0, :colour => ' b ').colour.
|
65
|
-
Result.new(4, 1, 0, :colour => ' BLACK ').colour.
|
66
|
-
|
61
|
+
expect(Result.new(4, 1, 0).colour).to be_nil
|
62
|
+
expect(Result.new(4, 1, 0, :colour => 'W').colour).to eq('W')
|
63
|
+
expect(Result.new(4, 1, 0, :colour => 'white').colour).to eq('W')
|
64
|
+
expect(Result.new(4, 1, 0, :colour => ' b ').colour).to eq('B')
|
65
|
+
expect(Result.new(4, 1, 0, :colour => ' BLACK ').colour).to eq('B')
|
66
|
+
expect { Result.new(4, 1, 0, :colour => 'red') }.to raise_error(/invalid colour/)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
context "opponent number" do
|
71
71
|
it "should be nil (the default) or an integer" do
|
72
|
-
Result.new(4, 1, 0).opponent.
|
73
|
-
Result.new(4, 1, 0, :opponent => nil).opponent.
|
74
|
-
Result.new(4, 1, 0, :opponent => ' ').opponent.
|
75
|
-
Result.new(4, 1, 0, :opponent => 0).opponent.
|
76
|
-
Result.new(4, 1, 0, :opponent => 2).opponent.
|
77
|
-
Result.new(4, 1, 0, :opponent => -6).opponent.
|
78
|
-
Result.new(4, 1, 0, :opponent => ' 10 ').opponent.
|
79
|
-
|
72
|
+
expect(Result.new(4, 1, 0).opponent).to be_nil
|
73
|
+
expect(Result.new(4, 1, 0, :opponent => nil).opponent).to be_nil
|
74
|
+
expect(Result.new(4, 1, 0, :opponent => ' ').opponent).to be_nil
|
75
|
+
expect(Result.new(4, 1, 0, :opponent => 0).opponent).to eq(0)
|
76
|
+
expect(Result.new(4, 1, 0, :opponent => 2).opponent).to eq(2)
|
77
|
+
expect(Result.new(4, 1, 0, :opponent => -6).opponent).to eq(-6)
|
78
|
+
expect(Result.new(4, 1, 0, :opponent => ' 10 ').opponent).to eq(10)
|
79
|
+
expect { Result.new(4, 1, 0, :opponent => 'X') }.to raise_error(/invalid opponent number/)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should be different to player number" do
|
83
|
-
|
83
|
+
expect { Result.new(4, 1, 0, :opponent => 1) }.to raise_error(/opponent .* player .* different/)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
context "rateable flag" do
|
88
88
|
it "should default to false if there is no opponent" do
|
89
|
-
Result.new(4, 1, 0).rateable.
|
89
|
+
expect(Result.new(4, 1, 0).rateable).to be_falsey
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should default to true if there is an opponent" do
|
93
|
-
Result.new(4, 1, 0, :opponent => 10).rateable.
|
93
|
+
expect(Result.new(4, 1, 0, :opponent => 10).rateable).to be_truthy
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should change if an opponent is added" do
|
97
97
|
r = Result.new(4, 1, 0)
|
98
98
|
r.opponent = 5;
|
99
|
-
r.rateable.
|
99
|
+
expect(r.rateable).to be_truthy
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should be settable to false from the constructor" do
|
103
|
-
Result.new(4, 1, 0, :opponent => 10, :rateable => false).rateable.
|
103
|
+
expect(Result.new(4, 1, 0, :opponent => 10, :rateable => false).rateable).to be_falsey
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should be settable to false using the accessor" do
|
107
107
|
r = Result.new(4, 1, 0, :opponent => 10)
|
108
108
|
r.rateable= false
|
109
|
-
r.rateable.
|
109
|
+
expect(r.rateable).to be_falsey
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should not be settable to true if there is no opponent" do
|
113
113
|
r = Result.new(4, 1, 0)
|
114
114
|
r.rateable= true
|
115
|
-
r.rateable.
|
115
|
+
expect(r.rateable).to be_falsey
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
context "reversed result" do
|
120
120
|
it "should be nil if there is no opponent" do
|
121
|
-
Result.new(4, 1, 0).reverse.
|
121
|
+
expect(Result.new(4, 1, 0).reverse).to be_nil
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should have player and opponent swapped" do
|
125
125
|
r = Result.new(4, 1, 0, :opponent => 2).reverse
|
126
|
-
r.player.
|
127
|
-
r.opponent.
|
126
|
+
expect(r.player).to eq(2)
|
127
|
+
expect(r.opponent).to eq(1)
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should have reversed result" do
|
131
|
-
Result.new(4, 1, 0, :opponent => 2).reverse.score.
|
132
|
-
Result.new(4, 1, 1, :opponent => 2).reverse.score.
|
133
|
-
Result.new(4, 1, '=', :opponent => 2).reverse.score.
|
131
|
+
expect(Result.new(4, 1, 0, :opponent => 2).reverse.score).to eq('W')
|
132
|
+
expect(Result.new(4, 1, 1, :opponent => 2).reverse.score).to eq('L')
|
133
|
+
expect(Result.new(4, 1, '=', :opponent => 2).reverse.score).to eq('D')
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should preserve rateability" do
|
137
|
-
Result.new(4, 1, 0, :opponent => 2).reverse.rateable.
|
138
|
-
Result.new(4, 1, 0, :opponent => 2, :rateable => false).reverse.rateable.
|
137
|
+
expect(Result.new(4, 1, 0, :opponent => 2).reverse.rateable).to be_truthy
|
138
|
+
expect(Result.new(4, 1, 0, :opponent => 2, :rateable => false).reverse.rateable).to be_falsey
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -147,14 +147,14 @@ module ICU
|
|
147
147
|
|
148
148
|
it "should renumber successfully if the map has the relevant player numbers" do
|
149
149
|
map = { 4 => 1, 3 => 2 }
|
150
|
-
@r1.renumber(map).player.
|
151
|
-
@r2.renumber(map).player.
|
152
|
-
@r1.opponent.
|
153
|
-
@r2.opponent.
|
150
|
+
expect(@r1.renumber(map).player).to eq(1)
|
151
|
+
expect(@r2.renumber(map).player).to eq(2)
|
152
|
+
expect(@r1.opponent).to be_nil
|
153
|
+
expect(@r2.opponent).to eq(1)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should raise exception if a player number is not in the map" do
|
157
|
-
|
157
|
+
expect { @r1.renumber({ 5 => 1, 3 => 2 }) }.to raise_error(/player.*4.*not found/)
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -169,19 +169,19 @@ module ICU
|
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should only be equal if everything is the same" do
|
172
|
-
@r.eql?(@r).
|
173
|
-
@r.eql?(@r1).
|
174
|
-
@r.eql?(@r2).
|
175
|
-
@r.eql?(@r3).
|
176
|
-
@r.eql?(@r4).
|
177
|
-
@r.eql?(@r5).
|
172
|
+
expect(@r.eql?(@r)).to be_truthy
|
173
|
+
expect(@r.eql?(@r1)).to be_truthy
|
174
|
+
expect(@r.eql?(@r2)).to be_falsey
|
175
|
+
expect(@r.eql?(@r3)).to be_falsey
|
176
|
+
expect(@r.eql?(@r4)).to be_falsey
|
177
|
+
expect(@r.eql?(@r5)).to be_falsey
|
178
178
|
end
|
179
179
|
|
180
180
|
it "exceptions are allowed" do
|
181
|
-
@r.eql?(@r2, :except => :rateable).
|
182
|
-
@r.eql?(@r3, :except => "round").
|
183
|
-
@r.eql?(@r4, :except => :colour).
|
184
|
-
@r.eql?(@r5, :except => [:colour, :round, :score, "opponent"]).
|
181
|
+
expect(@r.eql?(@r2, :except => :rateable)).to be_truthy
|
182
|
+
expect(@r.eql?(@r3, :except => "round")).to be_truthy
|
183
|
+
expect(@r.eql?(@r4, :except => :colour)).to be_truthy
|
184
|
+
expect(@r.eql?(@r5, :except => [:colour, :round, :score, "opponent"])).to be_truthy
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
@@ -194,11 +194,11 @@ module ICU
|
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should be correct" do
|
197
|
-
@r.eql?(@r1).
|
198
|
-
@r.eql?(@r2).
|
199
|
-
@r.eql?(@r3).
|
200
|
-
@r.eql?(@r2, :except => :rateable).
|
201
|
-
@r.eql?(@r3, :except => [:rateable, :score]).
|
197
|
+
expect(@r.eql?(@r1)).to be_truthy
|
198
|
+
expect(@r.eql?(@r2)).to be_falsey
|
199
|
+
expect(@r.eql?(@r3)).to be_falsey
|
200
|
+
expect(@r.eql?(@r2, :except => :rateable)).to be_truthy
|
201
|
+
expect(@r.eql?(@r3, :except => [:rateable, :score])).to be_truthy
|
202
202
|
end
|
203
203
|
end
|
204
204
|
end
|
data/spec/team_spec.rb
CHANGED
@@ -11,49 +11,49 @@ module ICU
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should have a name" do
|
14
|
-
@t.name.
|
14
|
+
expect(@t.name).to eq('Wandering Dragons')
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should have some members" do
|
18
|
-
@t.
|
19
|
-
@t.include?(0).
|
20
|
-
@t.include?(3).
|
21
|
-
@t.include?(-7).
|
22
|
-
@t.include?(7).
|
18
|
+
expect(@t.members.size).to eq(3)
|
19
|
+
expect(@t.include?(0)).to be_truthy
|
20
|
+
expect(@t.include?(3)).to be_truthy
|
21
|
+
expect(@t.include?(-7)).to be_truthy
|
22
|
+
expect(@t.include?(7)).to be_falsey
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should match names ignoring case and irrelevant whitespace" do
|
26
|
-
@t.matches('Wandering Dragons').
|
27
|
-
@t.matches(' wandering dragons ').
|
28
|
-
@t.matches(' wanderingdragons ').
|
29
|
-
@t.matches('Blundering Bishops').
|
26
|
+
expect(@t.matches('Wandering Dragons')).to be_truthy
|
27
|
+
expect(@t.matches(' wandering dragons ')).to be_truthy
|
28
|
+
expect(@t.matches(' wanderingdragons ')).to be_falsey
|
29
|
+
expect(@t.matches('Blundering Bishops')).to be_falsey
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should have a changeable name with irrelevant whitespace being trimmed" do
|
33
33
|
@t.name = ' blue dragons '
|
34
|
-
@t.name.
|
34
|
+
expect(@t.name).to eq('blue dragons')
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should blowup if an attempt is made to blank the name" do
|
38
|
-
|
38
|
+
expect { @t.name = ' ' }.to raise_error(/blank/)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should blowup if an attempt is made to add a non-number" do
|
42
|
-
|
42
|
+
expect { @t.add_member(' ') }.to raise_error(/number/)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should blow up if an attempt is made to add a duplicate number" do
|
46
|
-
|
46
|
+
expect { @t.add_member(3) }.to raise_error(/duplicate/)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should renumber successfully if the map has the relevant player numbers" do
|
50
50
|
map = { 0 => 1, 3 => 2, -7 => 3 }
|
51
51
|
@t.renumber(map)
|
52
|
-
@t.members.sort.join('').
|
52
|
+
expect(@t.members.sort.join('')).to eq('123')
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should raise exception if a player is missing from the renumber map" do
|
56
|
-
|
56
|
+
expect { @t.renumber({ 5 => 1, 3 => 2 }) }.to raise_error(/player.*not found/)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/spec/tie_break_spec.rb
CHANGED
@@ -4,84 +4,84 @@ module ICU
|
|
4
4
|
describe TieBreak do
|
5
5
|
context "#identify which rule" do
|
6
6
|
it "should recognize Buchholz" do
|
7
|
-
TieBreak.identify(:buchholz).id.
|
8
|
-
TieBreak.identify(" BucholtS ").id.
|
9
|
-
TieBreak.identify(" bh ").id.
|
10
|
-
TieBreak.identify(" buccholts ").code.
|
7
|
+
expect(TieBreak.identify(:buchholz).id).to eq(:buchholz)
|
8
|
+
expect(TieBreak.identify(" BucholtS ").id).to eq(:buchholz)
|
9
|
+
expect(TieBreak.identify(" bh ").id).to eq(:buchholz)
|
10
|
+
expect(TieBreak.identify(" buccholts ").code).to eq("BH")
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should recognize Harkness (Median)" do
|
14
|
-
TieBreak.identify(:harkness).id.
|
15
|
-
TieBreak.identify("median").id.
|
16
|
-
TieBreak.identify(" hARKNES ").id.
|
17
|
-
TieBreak.identify("HK").id.
|
18
|
-
TieBreak.identify("MEDIAN").code.
|
14
|
+
expect(TieBreak.identify(:harkness).id).to eq(:harkness)
|
15
|
+
expect(TieBreak.identify("median").id).to eq(:harkness)
|
16
|
+
expect(TieBreak.identify(" hARKNES ").id).to eq(:harkness)
|
17
|
+
expect(TieBreak.identify("HK").id).to eq(:harkness)
|
18
|
+
expect(TieBreak.identify("MEDIAN").code).to eq("HK")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should recognize Modified Median" do
|
22
|
-
TieBreak.identify(:modified).id.
|
23
|
-
TieBreak.identify(" modified MEDIAN ").id.
|
24
|
-
TieBreak.identify("MM").code.
|
22
|
+
expect(TieBreak.identify(:modified).id).to eq(:modified_median)
|
23
|
+
expect(TieBreak.identify(" modified MEDIAN ").id).to eq(:modified_median)
|
24
|
+
expect(TieBreak.identify("MM").code).to eq("MM")
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should recognize Number of Blacks" do
|
28
|
-
TieBreak.identify(:blacks).id.
|
29
|
-
TieBreak.identify("number\tof\tblacks\n").id.
|
30
|
-
TieBreak.identify("\tnb\t").id.
|
31
|
-
TieBreak.identify("number_blacks").code.
|
28
|
+
expect(TieBreak.identify(:blacks).id).to eq(:blacks)
|
29
|
+
expect(TieBreak.identify("number\tof\tblacks\n").id).to eq(:blacks)
|
30
|
+
expect(TieBreak.identify("\tnb\t").id).to eq(:blacks)
|
31
|
+
expect(TieBreak.identify("number_blacks").code).to eq("NB")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should recognize Number of Wins" do
|
35
|
-
TieBreak.identify(:wins).id.
|
36
|
-
TieBreak.identify(" number-of-wins ").id.
|
37
|
-
TieBreak.identify("NUMBER WINS\r\n").id.
|
38
|
-
TieBreak.identify("nw").code.
|
35
|
+
expect(TieBreak.identify(:wins).id).to eq(:wins)
|
36
|
+
expect(TieBreak.identify(" number-of-wins ").id).to eq(:wins)
|
37
|
+
expect(TieBreak.identify("NUMBER WINS\r\n").id).to eq(:wins)
|
38
|
+
expect(TieBreak.identify("nw").code).to eq("NW")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should recognize Player's of Name" do
|
42
|
-
TieBreak.identify(:name).id.
|
43
|
-
TieBreak.identify("Player's Name").id.
|
44
|
-
TieBreak.identify("players_name").id.
|
45
|
-
TieBreak.identify("PN").id.
|
46
|
-
TieBreak.identify("PLAYER-NAME").code.
|
42
|
+
expect(TieBreak.identify(:name).id).to eq(:name)
|
43
|
+
expect(TieBreak.identify("Player's Name").id).to eq(:name)
|
44
|
+
expect(TieBreak.identify("players_name").id).to eq(:name)
|
45
|
+
expect(TieBreak.identify("PN").id).to eq(:name)
|
46
|
+
expect(TieBreak.identify("PLAYER-NAME").code).to eq("PN")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should recognize Sonneborn-Berger" do
|
50
|
-
TieBreak.identify(:sonneborn_berger).id.
|
51
|
-
TieBreak.identify(:neustadtl).id.
|
52
|
-
TieBreak.identify(" SONNEBORN\nberger").id.
|
53
|
-
TieBreak.identify("\t soneborn_berger \t").id.
|
54
|
-
TieBreak.identify("sb").id.
|
55
|
-
TieBreak.identify("NESTADL").code.
|
50
|
+
expect(TieBreak.identify(:sonneborn_berger).id).to eq(:neustadtl)
|
51
|
+
expect(TieBreak.identify(:neustadtl).id).to eq(:neustadtl)
|
52
|
+
expect(TieBreak.identify(" SONNEBORN\nberger").id).to eq(:neustadtl)
|
53
|
+
expect(TieBreak.identify("\t soneborn_berger \t").id).to eq(:neustadtl)
|
54
|
+
expect(TieBreak.identify("sb").id).to eq(:neustadtl)
|
55
|
+
expect(TieBreak.identify("NESTADL").code).to eq("SB")
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should recognize Sum of Progressive Scores" do
|
59
|
-
TieBreak.identify(:progressive).id.
|
60
|
-
TieBreak.identify("CUMULATIVE").id.
|
61
|
-
TieBreak.identify("sum of progressive scores").id.
|
62
|
-
TieBreak.identify("SUM-cumulative_SCORE").id.
|
63
|
-
TieBreak.identify(:cumulative_score).id.
|
64
|
-
TieBreak.identify("SumOfCumulative").id.
|
65
|
-
TieBreak.identify("SP").code.
|
59
|
+
expect(TieBreak.identify(:progressive).id).to eq(:progressive)
|
60
|
+
expect(TieBreak.identify("CUMULATIVE").id).to eq(:progressive)
|
61
|
+
expect(TieBreak.identify("sum of progressive scores").id).to eq(:progressive)
|
62
|
+
expect(TieBreak.identify("SUM-cumulative_SCORE").id).to eq(:progressive)
|
63
|
+
expect(TieBreak.identify(:cumulative_score).id).to eq(:progressive)
|
64
|
+
expect(TieBreak.identify("SumOfCumulative").id).to eq(:progressive)
|
65
|
+
expect(TieBreak.identify("SP").code).to eq("SP")
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should recognize Sum of Opponents' Ratings" do
|
69
|
-
TieBreak.identify(:ratings).id.
|
70
|
-
TieBreak.identify("sum of opponents ratings").id.
|
71
|
-
TieBreak.identify("Opponents' Ratings").id.
|
72
|
-
TieBreak.identify("SR").id.
|
73
|
-
TieBreak.identify("SUMOPPONENTSRATINGS").code.
|
69
|
+
expect(TieBreak.identify(:ratings).id).to eq(:ratings)
|
70
|
+
expect(TieBreak.identify("sum of opponents ratings").id).to eq(:ratings)
|
71
|
+
expect(TieBreak.identify("Opponents' Ratings").id).to eq(:ratings)
|
72
|
+
expect(TieBreak.identify("SR").id).to eq(:ratings)
|
73
|
+
expect(TieBreak.identify("SUMOPPONENTSRATINGS").code).to eq("SR")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should recognize player's name" do
|
77
|
-
TieBreak.identify(:name).id.
|
78
|
-
TieBreak.identify(" player's NAME ").id.
|
79
|
-
TieBreak.identify("pn").code.
|
77
|
+
expect(TieBreak.identify(:name).id).to eq(:name)
|
78
|
+
expect(TieBreak.identify(" player's NAME ").id).to eq(:name)
|
79
|
+
expect(TieBreak.identify("pn").code).to eq("PN")
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should return nil for unrecognized tie breaks" do
|
83
|
-
TieBreak.identify("XYZ").
|
84
|
-
TieBreak.identify(nil).
|
83
|
+
expect(TieBreak.identify("XYZ")).to be_nil
|
84
|
+
expect(TieBreak.identify(nil)).to be_nil
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -91,9 +91,9 @@ module ICU
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should be an array in a specific order" do
|
94
|
-
@rules.size.
|
95
|
-
@rules.first.name.
|
96
|
-
@rules.map(&:code).join("|").
|
94
|
+
expect(@rules.size).to eq(9)
|
95
|
+
expect(@rules.first.name).to eq("Buchholz")
|
96
|
+
expect(@rules.map(&:code).join("|")).to eq("BH|HK|MM|NB|NW|PN|SB|SR|SP")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|