icu_ratings 1.8.2 → 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +1 -1
- data/lib/icu_ratings/version.rb +1 -1
- data/spec/player_spec.rb +84 -84
- data/spec/result_spec.rb +27 -27
- data/spec/tournament_spec.rb +304 -304
- data/spec/util_spec.rb +19 -19
- metadata +26 -42
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba52aa09adfeab3a2c91eca7e9f82864d54d3bba
|
4
|
+
data.tar.gz: 92feb5576f6a87a390875ad8d09869fe233cc9c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c06150bd0a95a3830ecd699b3798ecce39a9c13047aac70576fbae7f1ec3b80db680276476fec1eb448c0d057cf90232a2fec35a03fde34d6f5885431b431631
|
7
|
+
data.tar.gz: 471a2e5ceb94f4ec78188b1102627a123d4b357acae5b3ad638e34d3ad6cbf44a1f192f80fe98ae1588831bf76c2b46c747b0ce8e3161bf976a7c15bc56088ed
|
data/README.rdoc
CHANGED
@@ -14,7 +14,7 @@ with only a provisional rating or without any prior rating) which is different t
|
|
14
14
|
|
15
15
|
sudo gem install icu_ratings
|
16
16
|
|
17
|
-
Tested on Ruby 1.9.2, 1.9.3 and 2.
|
17
|
+
Tested on Ruby 1.9.2, 1.9.3, 2.2.0 and 2.2.0. Version 1.0.5 was the last to support Ruby 1.8.7.
|
18
18
|
|
19
19
|
== Usage
|
20
20
|
|
data/lib/icu_ratings/version.rb
CHANGED
data/spec/player_spec.rb
CHANGED
@@ -12,35 +12,35 @@ module ICU
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "rated players have a rating and k-factor" do
|
15
|
-
@r.num.
|
16
|
-
@r.rating.
|
17
|
-
@r.kfactor.
|
18
|
-
@r.type.
|
19
|
-
@r.
|
15
|
+
expect(@r.num).to eq(1)
|
16
|
+
expect(@r.rating).to eq(2000)
|
17
|
+
expect(@r.kfactor).to eq(10.0)
|
18
|
+
expect(@r.type).to eq(:rated)
|
19
|
+
expect(@r).not_to respond_to(:games)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "provisionally rated players have a rating and number of games" do
|
23
|
-
@p.num.
|
24
|
-
@p.rating.
|
25
|
-
@p.games.
|
26
|
-
@p.type.
|
27
|
-
@p.
|
23
|
+
expect(@p.num).to eq(2)
|
24
|
+
expect(@p.rating).to eq(1500)
|
25
|
+
expect(@p.games).to eq(10)
|
26
|
+
expect(@p.type).to eq(:provisional)
|
27
|
+
expect(@p).not_to respond_to(:kfactor)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "foreign players just have a rating" do
|
31
|
-
@f.num.
|
32
|
-
@f.rating.
|
33
|
-
@f.type.
|
34
|
-
@f.
|
35
|
-
@f.
|
31
|
+
expect(@f.num).to eq(3)
|
32
|
+
expect(@f.rating).to eq(2500)
|
33
|
+
expect(@f.type).to eq(:foreign)
|
34
|
+
expect(@f).not_to respond_to(:kfactor)
|
35
|
+
expect(@f).not_to respond_to(:games)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "unrated players just have nothing other than their number" do
|
39
|
-
@u.num.
|
40
|
-
@u.type.
|
41
|
-
@u.
|
42
|
-
@u.
|
43
|
-
@u.
|
39
|
+
expect(@u.num).to eq(4)
|
40
|
+
expect(@u.type).to eq(:unrated)
|
41
|
+
expect(@u).not_to respond_to(:rating)
|
42
|
+
expect(@u).not_to respond_to(:kfactor)
|
43
|
+
expect(@u).not_to respond_to(:games)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "other combinations are invalid" do
|
@@ -49,52 +49,52 @@ module ICU
|
|
49
49
|
{ :games => 10, :kfactor => 10 },
|
50
50
|
{ :games => 10, :kfactor => 10, :rating => 1000 },
|
51
51
|
{ :kfactor => 10 },
|
52
|
-
].each { |opts|
|
52
|
+
].each { |opts| expect { ICU::RatedPlayer.factory(1, opts) }.to raise_error(/invalid.*combination/i) }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
context "#new - miscellaneous" do
|
57
57
|
it "attribute values can be given by strings, even when space padded" do
|
58
58
|
p = ICU::RatedPlayer.factory(' 1 ', :kfactor => ' 10.0 ', :rating => ' 1000 ')
|
59
|
-
p.num.
|
60
|
-
p.kfactor.
|
61
|
-
p.rating.
|
59
|
+
expect(p.num).to eq(1)
|
60
|
+
expect(p.kfactor).to eq(10.0)
|
61
|
+
expect(p.rating).to eq(1000)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
context "restrictions, or lack thereof, on attributes" do
|
66
66
|
it "the player number can be zero or even negative" do
|
67
|
-
|
68
|
-
|
67
|
+
expect { ICU::RatedPlayer.factory(-1) }.not_to raise_error
|
68
|
+
expect { ICU::RatedPlayer.factory(0) }.not_to raise_error
|
69
69
|
end
|
70
70
|
|
71
71
|
it "k-factors must be positive" do
|
72
|
-
|
73
|
-
|
72
|
+
expect { ICU::RatedPlayer.factory(1, :kfactor => 0) }.to raise_error(/invalid.*factor/i)
|
73
|
+
expect { ICU::RatedPlayer.factory(1, :kfactor => -1) }.to raise_error(/invalid.*factor/i)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "the rating can be zero or even negative" do
|
77
|
-
|
78
|
-
|
77
|
+
expect { ICU::RatedPlayer.factory(1, :rating => 0) }.not_to raise_error
|
78
|
+
expect { ICU::RatedPlayer.factory(1, :rating => -1) }.not_to raise_error
|
79
79
|
end
|
80
80
|
|
81
81
|
it "ratings are stored as floats but can be specified with an integer" do
|
82
|
-
ICU::RatedPlayer.factory(1, :rating => 1234.5).rating.
|
83
|
-
ICU::RatedPlayer.factory(1, :rating => 1234.0).rating.
|
84
|
-
ICU::RatedPlayer.factory(1, :rating => 1234).rating.
|
82
|
+
expect(ICU::RatedPlayer.factory(1, :rating => 1234.5).rating).to eq(1234.5)
|
83
|
+
expect(ICU::RatedPlayer.factory(1, :rating => 1234.0).rating).to eq(1234)
|
84
|
+
expect(ICU::RatedPlayer.factory(1, :rating => 1234).rating).to eq(1234)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "the number of games shoud not exceed 20" do
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
expect { ICU::RatedPlayer.factory(1, :rating => 1000, :games => 19) }.not_to raise_error
|
89
|
+
expect { ICU::RatedPlayer.factory(1, :rating => 1000, :games => 20) }.to raise_error
|
90
|
+
expect { ICU::RatedPlayer.factory(1, :rating => 1000, :games => 21) }.to raise_error
|
91
91
|
end
|
92
92
|
|
93
93
|
it "a description, such as a name, but can be any object, is optional" do
|
94
|
-
ICU::RatedPlayer.factory(1, :desc => 'Fischer, Robert').desc.
|
95
|
-
ICU::RatedPlayer.factory(1, :desc => 1).desc.
|
96
|
-
ICU::RatedPlayer.factory(1, :desc => 1.0).desc.
|
97
|
-
ICU::RatedPlayer.factory(1).desc.
|
94
|
+
expect(ICU::RatedPlayer.factory(1, :desc => 'Fischer, Robert').desc).to eq('Fischer, Robert')
|
95
|
+
expect(ICU::RatedPlayer.factory(1, :desc => 1).desc).to be_an_instance_of(Fixnum)
|
96
|
+
expect(ICU::RatedPlayer.factory(1, :desc => 1.0).desc).to be_an_instance_of(Float)
|
97
|
+
expect(ICU::RatedPlayer.factory(1).desc).to be_nil
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -108,58 +108,58 @@ module ICU
|
|
108
108
|
|
109
109
|
it "should be returned in round order" do
|
110
110
|
@p.add_result(@r2)
|
111
|
-
@p.results.size.
|
112
|
-
@p.results[0].
|
111
|
+
expect(@p.results.size).to eq(1)
|
112
|
+
expect(@p.results[0]).to eq(@r2)
|
113
113
|
@p.add_result(@r3)
|
114
|
-
@p.results.size.
|
115
|
-
@p.results[0].
|
116
|
-
@p.results[1].
|
114
|
+
expect(@p.results.size).to eq(2)
|
115
|
+
expect(@p.results[0]).to eq(@r2)
|
116
|
+
expect(@p.results[1]).to eq(@r3)
|
117
117
|
@p.add_result(@r1)
|
118
|
-
@p.results.size.
|
119
|
-
@p.results[0].
|
120
|
-
@p.results[1].
|
121
|
-
@p.results[2].
|
118
|
+
expect(@p.results.size).to eq(3)
|
119
|
+
expect(@p.results[0]).to eq(@r1)
|
120
|
+
expect(@p.results[1]).to eq(@r2)
|
121
|
+
expect(@p.results[2]).to eq(@r3)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "the total score should stay consistent with results as they are added" do
|
125
|
-
@p.score.
|
125
|
+
expect(@p.score).to eq(0.0)
|
126
126
|
@p.add_result(@r1)
|
127
|
-
@p.score.
|
127
|
+
expect(@p.score).to eq(1.0)
|
128
128
|
@p.add_result(@r2)
|
129
|
-
@p.score.
|
129
|
+
expect(@p.score).to eq(1.0)
|
130
130
|
@p.add_result(@r3)
|
131
|
-
@p.score.
|
131
|
+
expect(@p.score).to eq(1.5)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
context "calculation of K-factor" do
|
136
136
|
it "should return 16 for players 2100 and above" do
|
137
|
-
ICU::RatedPlayer.kfactor(:rating => 2101, :start => '2010-07-10', :dob => '1955-11-09', :joined => '1974-01-01').
|
138
|
-
ICU::RatedPlayer.kfactor(:rating => 2100, :start => '2010-07-10', :dob => '1955-11-09', :joined => '1974-01-01').
|
139
|
-
ICU::RatedPlayer.kfactor(:rating => 2099, :start => '2010-07-10', :dob => '1955-11-09', :joined => '1974-01-01').
|
137
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2101, :start => '2010-07-10', :dob => '1955-11-09', :joined => '1974-01-01')).to eq(16)
|
138
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2100, :start => '2010-07-10', :dob => '1955-11-09', :joined => '1974-01-01')).to eq(16)
|
139
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2099, :start => '2010-07-10', :dob => '1955-11-09', :joined => '1974-01-01')).not_to eq(16)
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should otherwise return 40 for players aged under 21 at the start of the tournament" do
|
143
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-07-11', :joined => '1999-01-01').
|
144
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-07-10', :joined => '1999-01-01').
|
145
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-07-09', :joined => '1999-01-01').
|
143
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-07-11', :joined => '1999-01-01')).to eq(40)
|
144
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-07-10', :joined => '1999-01-01')).not_to eq(40)
|
145
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-07-09', :joined => '1999-01-01')).not_to eq(40)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should otherwise return 32 for players with under 8 years experience at the start of the tournament" do
|
149
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-07-11').
|
150
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-07-10').
|
151
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-07-09').
|
149
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-07-11')).to eq(32)
|
150
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-07-10')).not_to eq(32)
|
151
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-07-09')).not_to eq(32)
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should otherwise return 24" do
|
155
|
-
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-01-01').
|
155
|
+
expect(ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-01-01')).to eq(24)
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should throw an exception if required information is missing" do
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
159
|
+
expect { ICU::RatedPlayer.kfactor(:start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-01-01') }.to raise_error(/missing.*rating/)
|
160
|
+
expect { ICU::RatedPlayer.kfactor(:rating => 2000, :dob => '1989-01-01', :joined => '2002-01-01') }.to raise_error(/missing.*start/)
|
161
|
+
expect { ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :joined => '2002-01-01') }.to raise_error(/missing.*dob/)
|
162
|
+
expect { ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01') }.to raise_error(/missing.*join/)
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -170,38 +170,38 @@ module ICU
|
|
170
170
|
end
|
171
171
|
|
172
172
|
it "the same player number can't be added twice" do
|
173
|
-
|
174
|
-
|
173
|
+
expect { @t.add_player(2) }.not_to raise_error
|
174
|
+
expect { @t.add_player(2) }.to raise_error
|
175
175
|
end
|
176
176
|
|
177
177
|
it "parameters can be specified using strings, even with whitespace padding" do
|
178
178
|
p = @t.add_player(" 0 ", :rating => " 2000.5 ", :kfactor => " 20.5 ")
|
179
|
-
p.num.
|
180
|
-
p.num.
|
181
|
-
p.rating.
|
182
|
-
p.rating.
|
183
|
-
p.kfactor.
|
184
|
-
p.kfactor.
|
179
|
+
expect(p.num).to eq(0)
|
180
|
+
expect(p.num).to be_an_instance_of(Fixnum)
|
181
|
+
expect(p.rating).to eq(2000.5)
|
182
|
+
expect(p.rating).to be_an_instance_of(Float)
|
183
|
+
expect(p.kfactor).to eq(20.5)
|
184
|
+
expect(p.kfactor).to be_an_instance_of(Float)
|
185
185
|
p = @t.add_player(" -1 ", :rating => " 2000.5 ", :games => " 15 ")
|
186
|
-
p.games.
|
187
|
-
p.games.
|
186
|
+
expect(p.games).to eq(15)
|
187
|
+
expect(p.games).to be_an_instance_of(Fixnum)
|
188
188
|
end
|
189
189
|
|
190
190
|
it "the games parameter should not exceed 20" do
|
191
|
-
|
191
|
+
expect { @t.add_player(2, :rating => 1500, :games => 20 ) }.to raise_error
|
192
192
|
end
|
193
193
|
|
194
194
|
it "adding different player types" do
|
195
195
|
p = @t.add_player(3, :rating => 2000, :kfactor => 16)
|
196
|
-
p.type.
|
196
|
+
expect(p.type).to eq(:rated)
|
197
197
|
p = @t.add_player(4, :rating => 1600, :games => 10)
|
198
|
-
p.type.
|
198
|
+
expect(p.type).to eq(:provisional)
|
199
199
|
p = @t.add_player(5)
|
200
|
-
p.type.
|
200
|
+
expect(p.type).to eq(:unrated)
|
201
201
|
p = @t.add_player(6, :rating => 2500)
|
202
|
-
p.type.
|
203
|
-
|
204
|
-
|
202
|
+
expect(p.type).to eq(:foreign)
|
203
|
+
expect { @t.add_player(7, :rating => 2000, :kfactor => 16, :games => 10) }.to raise_error
|
204
|
+
expect { t.add_plater(7, :kfactor => 16) }.to raise_error
|
205
205
|
end
|
206
206
|
end
|
207
207
|
end
|
data/spec/result_spec.rb
CHANGED
@@ -10,9 +10,9 @@ module ICU
|
|
10
10
|
|
11
11
|
it "needs a round, opponent and score (win, loss or draw)" do
|
12
12
|
r = ICU::RatedResult.new(1, @o, 'W')
|
13
|
-
r.round.
|
14
|
-
r.opponent.
|
15
|
-
r.score.
|
13
|
+
expect(r.round).to eq(1)
|
14
|
+
expect(r.opponent).to be_a_kind_of(ICU::RatedPlayer)
|
15
|
+
expect(r.score).to eq(1.0)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -22,20 +22,20 @@ module ICU
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "round numbers must be positive" do
|
25
|
-
|
26
|
-
|
25
|
+
expect { ICU::RatedResult.new(0, 1, 'W') }.to raise_error(/invalid.*round number/i)
|
26
|
+
expect { ICU::RatedResult.new(-1, 1, 'W') }.to raise_error(/invalid.*round number/i)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "the opponent must be an object, not a number" do
|
30
|
-
|
31
|
-
|
30
|
+
expect { ICU::RatedResult.new(1, 0, 'W') }.to raise_error(/invalid.*class.*Fixnum/)
|
31
|
+
expect { ICU::RatedResult.new(1, @p, 'W') }.not_to raise_error
|
32
32
|
end
|
33
33
|
|
34
34
|
it "the score can be any of the usual suspects" do
|
35
|
-
['W', 'w', 1, 1.0].each { |r| ICU::RatedResult.new(1, @p, r).score.
|
36
|
-
['L', 'l', 0, 0.0].each { |r| ICU::RatedResult.new(1, @p, r).score.
|
37
|
-
['D', 'd', '½', 0.5].each { |r| ICU::RatedResult.new(1, @p, r).score.
|
38
|
-
|
35
|
+
['W', 'w', 1, 1.0].each { |r| expect(ICU::RatedResult.new(1, @p, r).score).to eq(1.0) }
|
36
|
+
['L', 'l', 0, 0.0].each { |r| expect(ICU::RatedResult.new(1, @p, r).score).to eq(0.0) }
|
37
|
+
['D', 'd', '½', 0.5].each { |r| expect(ICU::RatedResult.new(1, @p, r).score).to eq(0.5) }
|
38
|
+
expect { ICU::RatedResult.new(1, @p, '') }.to raise_error(/invalid.*score/)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -45,9 +45,9 @@ module ICU
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should give the score from the opponent's perspective" do
|
48
|
-
ICU::RatedResult.new(1, @p, 'W').opponents_score.
|
49
|
-
ICU::RatedResult.new(1, @p, 'L').opponents_score.
|
50
|
-
ICU::RatedResult.new(1, @p, 'D').opponents_score.
|
48
|
+
expect(ICU::RatedResult.new(1, @p, 'W').opponents_score).to eq(0.0)
|
49
|
+
expect(ICU::RatedResult.new(1, @p, 'L').opponents_score).to eq(1.0)
|
50
|
+
expect(ICU::RatedResult.new(1, @p, 'D').opponents_score).to eq(0.5)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -63,10 +63,10 @@ module ICU
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should return true only if all attributes match" do
|
66
|
-
(@r1 == @r2).
|
67
|
-
(@r1 == @r3).
|
68
|
-
(@r1 == @r4).
|
69
|
-
(@r1 == @r5).
|
66
|
+
expect(@r1 == @r2).to be_truthy
|
67
|
+
expect(@r1 == @r3).to be_falsey
|
68
|
+
expect(@r1 == @r4).to be_falsey
|
69
|
+
expect(@r1 == @r5).to be_falsey
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -83,24 +83,24 @@ module ICU
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "it is OK but unnecessary to add the same result from the other players perspective" do
|
86
|
-
@t.player(10).results.size.
|
87
|
-
@t.player(20).results.size.
|
88
|
-
|
89
|
-
@t.player(10).results.size.
|
90
|
-
@t.player(20).results.size.
|
86
|
+
expect(@t.player(10).results.size).to eq(1)
|
87
|
+
expect(@t.player(20).results.size).to eq(1)
|
88
|
+
expect { @t.add_result(1, 20, 10, 'L') }.not_to raise_error
|
89
|
+
expect(@t.player(10).results.size).to eq(1)
|
90
|
+
expect(@t.player(20).results.size).to eq(1)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "adding results against other players in the same round will cause an exception" do
|
94
|
-
|
95
|
-
|
94
|
+
expect { @t.add_result(1, 10, 30, 'W') }.to raise_error(/inconsistent/i)
|
95
|
+
expect { @t.add_result(1, 10, 20, 'L') }.to raise_error(/inconsistent/i)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "a player cannot have a result against himself/herself" do
|
99
|
-
|
99
|
+
expect { @t.add_result(2, 10, 10, 'D') }.to raise_error(/players.*cannot.*sel[fv]/i)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "results are returned in score order irrespecive of the order they're added in" do
|
103
|
-
@t.player(0).results.map{ |r| r.round }.join(',').
|
103
|
+
expect(@t.player(0).results.map{ |r| r.round }.join(',')).to eq("1,2,3,4")
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
data/spec/tournament_spec.rb
CHANGED
@@ -5,25 +5,25 @@ module ICU
|
|
5
5
|
describe RatedTournament do
|
6
6
|
context "restrictions, or lack thereof, on attributes" do
|
7
7
|
it "a tournament can have an optional description, such as a name, but any object is allowed" do
|
8
|
-
ICU::RatedTournament.new(:desc => 'Irish Championship 2010').desc.
|
9
|
-
ICU::RatedTournament.new(:desc => 1.0).desc.
|
10
|
-
ICU::RatedTournament.new.desc.
|
8
|
+
expect(ICU::RatedTournament.new(:desc => 'Irish Championship 2010').desc).to eq('Irish Championship 2010')
|
9
|
+
expect(ICU::RatedTournament.new(:desc => 1.0).desc).to be_an_instance_of(Float)
|
10
|
+
expect(ICU::RatedTournament.new.desc).to be_nil
|
11
11
|
end
|
12
12
|
|
13
13
|
it "a tournament can have an optional start date" do
|
14
|
-
ICU::RatedTournament.new(:start => '2010-01-01').start.
|
15
|
-
ICU::RatedTournament.new(:start => '03/06/2013').start.to_s.
|
16
|
-
ICU::RatedTournament.new(:start => Date.parse('1955-11-09')).start.to_s.
|
17
|
-
ICU::RatedTournament.new.start.
|
18
|
-
|
14
|
+
expect(ICU::RatedTournament.new(:start => '2010-01-01').start).to be_a(Date)
|
15
|
+
expect(ICU::RatedTournament.new(:start => '03/06/2013').start.to_s).to eq('2013-06-03')
|
16
|
+
expect(ICU::RatedTournament.new(:start => Date.parse('1955-11-09')).start.to_s).to eq('1955-11-09')
|
17
|
+
expect(ICU::RatedTournament.new.start).to be_nil
|
18
|
+
expect { ICU::RatedTournament.new(:start => 'error') }.to raise_error
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should have setters for the optional arguments" do
|
22
22
|
t = ICU::RatedTournament.new
|
23
23
|
t.desc=("Championship")
|
24
24
|
t.start=("2010-07-01")
|
25
|
-
t.desc.
|
26
|
-
t.start.
|
25
|
+
expect(t.desc).to eq("Championship")
|
26
|
+
expect(t.start).to eq(Date.parse("2010-07-01"))
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -34,22 +34,22 @@ module ICU
|
|
34
34
|
|
35
35
|
it "should set a K-factor of 16 for players with rating >= 2100" do
|
36
36
|
@p = @t.add_player(1, :rating => 2200, :kfactor => { :dob => "1955-11-09", :joined => "1976-09-01" })
|
37
|
-
@p.kfactor.
|
37
|
+
expect(@p.kfactor).to eq(16)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should set a K-factor of 40 for players with rating < 2100 and age < 21" do
|
41
41
|
@p = @t.add_player(1, :rating => 2000, :kfactor => { :dob => "1995-01-10", :joined => "2009-09-01" })
|
42
|
-
@p.kfactor.
|
42
|
+
expect(@p.kfactor).to eq(40)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should set a K-factor of 32 for players with rating < 2100, age >= 21 and experience < 8" do
|
46
46
|
@p = @t.add_player(1, :rating => 2000, :kfactor => { :dob => "1975-01-10", :joined => "2005-09-01" })
|
47
|
-
@p.kfactor.
|
47
|
+
expect(@p.kfactor).to eq(32)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should set a K-factor of 24 for players with rating < 2100, age >= 21 and experience >= 8" do
|
51
51
|
@p = @t.add_player(1, :rating => 2000, :kfactor => { :dob => "1975-01-10", :joined => "1995-09-01" })
|
52
|
-
@p.kfactor.
|
52
|
+
expect(@p.kfactor).to eq(24)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -61,15 +61,15 @@ module ICU
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should return the players in number-order" do
|
64
|
-
@t.players.size.
|
65
|
-
@t.players[0].num.
|
66
|
-
@t.players[1].num.
|
64
|
+
expect(@t.players.size).to eq(2)
|
65
|
+
expect(@t.players[0].num).to eq(1)
|
66
|
+
expect(@t.players[1].num).to eq(2)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should return the player object with the matching number" do
|
70
|
-
@t.player(1).num.
|
71
|
-
@t.player(2).num.
|
72
|
-
@t.player(3).
|
70
|
+
expect(@t.player(1).num).to eq(1)
|
71
|
+
expect(@t.player(2).num).to eq(2)
|
72
|
+
expect(@t.player(3)).to be_nil
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -83,54 +83,54 @@ module ICU
|
|
83
83
|
|
84
84
|
it "should be added to both players" do
|
85
85
|
@t.add_result(1, @p1, @p2, 'L')
|
86
|
-
@p1.results.size.
|
87
|
-
@p1.results[0].
|
88
|
-
@p2.results.size.
|
89
|
-
@p2.results[0].
|
90
|
-
@p3.results.size.
|
86
|
+
expect(@p1.results.size).to eq(1)
|
87
|
+
expect(@p1.results[0]).to eq(ICU::RatedResult.new(1, @p2, 'L'))
|
88
|
+
expect(@p2.results.size).to eq(1)
|
89
|
+
expect(@p2.results[0]).to eq(ICU::RatedResult.new(1, @p1, 'W'))
|
90
|
+
expect(@p3.results.size).to eq(0)
|
91
91
|
@t.add_result(2, @p3, @p2, 'W')
|
92
|
-
@p1.results.size.
|
93
|
-
@p2.results.size.
|
94
|
-
@p2.results[0].
|
95
|
-
@p2.results[1].
|
96
|
-
@p3.results.size.
|
97
|
-
@p3.results[0].
|
92
|
+
expect(@p1.results.size).to eq(1)
|
93
|
+
expect(@p2.results.size).to eq(2)
|
94
|
+
expect(@p2.results[0]).to eq(ICU::RatedResult.new(1, @p1, 'W'))
|
95
|
+
expect(@p2.results[1]).to eq(ICU::RatedResult.new(2, @p3, 'L'))
|
96
|
+
expect(@p3.results.size).to eq(1)
|
97
|
+
expect(@p3.results[0]).to eq(ICU::RatedResult.new(2, @p2, 'W'))
|
98
98
|
end
|
99
99
|
|
100
100
|
it "player objects or numbers can be used" do
|
101
|
-
|
102
|
-
|
101
|
+
expect { @t.add_result(1, @p1, @p2, 'L') }.not_to raise_error
|
102
|
+
expect { @t.add_result(2, 1, 2, 'W') }.not_to raise_error
|
103
103
|
end
|
104
104
|
|
105
105
|
it "the player numbers should exist already in the tournament" do
|
106
|
-
|
107
|
-
|
106
|
+
expect { @t.add_result(2, 1, 4, 'W') }.to raise_error(/player number.*4/)
|
107
|
+
expect { @t.add_result(2, 5, 2, 'W') }.to raise_error(/player number.*5/)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "adding precisely the same result more than once is okay and changes nothing" do
|
111
111
|
@t.add_result(1, @p1, @p2, 'L')
|
112
112
|
@t.add_result(1, @p1, @p2, 'L')
|
113
113
|
@t.add_result(1, @p2, @p1, 'W')
|
114
|
-
@p1.results.size.
|
115
|
-
@p2.results.size.
|
114
|
+
expect(@p1.results.size).to eq(1)
|
115
|
+
expect(@p2.results.size).to eq(1)
|
116
116
|
end
|
117
117
|
|
118
118
|
it "a player cannot have two different results in the same round" do
|
119
119
|
@t.add_result(1, @p1, @p2, 'L')
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
expect { @t.add_result(1, @p1, @p2, 'W') }.to raise_error(/inconsistent/)
|
121
|
+
expect { @t.add_result(1, @p1, @p3, 'W') }.to raise_error(/inconsistent/)
|
122
|
+
expect { @t.add_result(1, @p3, @p2, 'W') }.to raise_error(/inconsistent/)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "players cannot have results against themselves" do
|
126
|
-
|
126
|
+
expect { @t.add_result(1, @p1, @p1, 'W') }.to raise_error(/against.*themsel(f|ves)/)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
context "#rate - corner case - tournament is empy" do
|
131
131
|
it "should not throw an exception" do
|
132
132
|
@t = ICU::RatedTournament.new
|
133
|
-
|
133
|
+
expect { @t.rate! }.not_to raise_error
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -151,29 +151,29 @@ module ICU
|
|
151
151
|
it "before the tournament is rated" do
|
152
152
|
(1..4).each do |num|
|
153
153
|
p = @t.player(num)
|
154
|
-
p.expected_score.
|
155
|
-
p.rating_change.
|
156
|
-
p.new_rating.
|
154
|
+
expect(p.expected_score).to eq(0.0)
|
155
|
+
expect(p.rating_change).to eq(0.0)
|
156
|
+
expect(p.new_rating).to eq(p.rating)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
160
|
it "after the tournament is rated" do
|
161
161
|
@t.rate!
|
162
162
|
|
163
|
-
@t.player(1).expected_score.
|
164
|
-
@t.player(2).expected_score.
|
165
|
-
@t.player(3).expected_score.
|
166
|
-
@t.player(4).expected_score.
|
163
|
+
expect(@t.player(1).expected_score).to be_within(0.001).of(2.249)
|
164
|
+
expect(@t.player(2).expected_score).to be_within(0.001).of(1.760)
|
165
|
+
expect(@t.player(3).expected_score).to be_within(0.001).of(1.240)
|
166
|
+
expect(@t.player(4).expected_score).to be_within(0.001).of(0.751)
|
167
167
|
|
168
|
-
@t.player(1).rating_change.
|
169
|
-
@t.player(2).rating_change.
|
170
|
-
@t.player(3).rating_change.
|
171
|
-
@t.player(4).rating_change.
|
168
|
+
expect(@t.player(1).rating_change).to be_within(0.01).of(7.51)
|
169
|
+
expect(@t.player(2).rating_change).to be_within(0.01).of(4.81)
|
170
|
+
expect(@t.player(3).rating_change).to be_within(0.01).of(-7.21)
|
171
|
+
expect(@t.player(4).rating_change).to be_within(0.01).of(-30.05)
|
172
172
|
|
173
|
-
@t.player(1).new_rating.
|
174
|
-
@t.player(2).new_rating.
|
175
|
-
@t.player(3).new_rating.
|
176
|
-
@t.player(4).new_rating.
|
173
|
+
expect(@t.player(1).new_rating).to be_within(0.1).of(2207.5)
|
174
|
+
expect(@t.player(2).new_rating).to be_within(0.1).of(2104.8)
|
175
|
+
expect(@t.player(3).new_rating).to be_within(0.1).of(1992.8)
|
176
|
+
expect(@t.player(4).new_rating).to be_within(0.1).of(1870.0)
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -229,8 +229,8 @@ module ICU
|
|
229
229
|
].each do |item|
|
230
230
|
num, expected_score, new_rating = item
|
231
231
|
p = @t.player(num)
|
232
|
-
p.expected_score.
|
233
|
-
p.new_rating.
|
232
|
+
expect(p.expected_score).to be_within(0.001).of(expected_score)
|
233
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
@@ -245,8 +245,8 @@ module ICU
|
|
245
245
|
].each do |item|
|
246
246
|
num, ytd_performance, tournament_performance = item
|
247
247
|
p = @t.player(num)
|
248
|
-
p.performance.
|
249
|
-
p.performance.
|
248
|
+
expect(p.performance).not_to be_within(0.5).of(ytd_performance)
|
249
|
+
expect(p.performance).to be_within(0.5).of(tournament_performance)
|
250
250
|
end
|
251
251
|
end
|
252
252
|
end
|
@@ -263,10 +263,10 @@ module ICU
|
|
263
263
|
end
|
264
264
|
|
265
265
|
it "should get same results as ICU rating database" do
|
266
|
-
@t.player(1).expected_score.
|
267
|
-
@t.player(2).expected_score.
|
268
|
-
@t.player(1).new_rating.
|
269
|
-
@t.player(2).new_rating.
|
266
|
+
expect(@t.player(1).expected_score).to be_within(0.001).of(1.689)
|
267
|
+
expect(@t.player(2).expected_score).to be_within(0.001).of(1.311)
|
268
|
+
expect(@t.player(1).new_rating).to be_within(0.5).of(1378)
|
269
|
+
expect(@t.player(2).new_rating).to be_within(0.5).of(1261)
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
@@ -342,9 +342,9 @@ module ICU
|
|
342
342
|
(3..20).each do |num|
|
343
343
|
unless num == 13
|
344
344
|
p = @t.player(num)
|
345
|
-
p.expected_score.
|
346
|
-
p.
|
347
|
-
p.new_rating.
|
345
|
+
expect(p.expected_score).not_to eq(0.0)
|
346
|
+
expect(p).not_to respond_to(:rating_change)
|
347
|
+
expect(p.new_rating).to eq(p.rating)
|
348
348
|
end
|
349
349
|
end
|
350
350
|
end
|
@@ -371,7 +371,7 @@ module ICU
|
|
371
371
|
].each do |item|
|
372
372
|
num, performance = item
|
373
373
|
p = @t.player(num)
|
374
|
-
p.performance.
|
374
|
+
expect(p.performance).to eq(performance)
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
@@ -379,13 +379,13 @@ module ICU
|
|
379
379
|
af = @t.player(1)
|
380
380
|
pc = @t.player(2)
|
381
381
|
|
382
|
-
af.score.
|
383
|
-
af.expected_score.
|
384
|
-
af.new_rating.
|
382
|
+
expect(af.score).to eq(4.5)
|
383
|
+
expect(af.expected_score).to be_within(0.001).of(6.054)
|
384
|
+
expect(af.new_rating).to be_within(0.5).of(2080)
|
385
385
|
|
386
|
-
pc.score.
|
387
|
-
pc.expected_score.
|
388
|
-
pc.new_rating.
|
386
|
+
expect(pc.score).to eq(4.0)
|
387
|
+
expect(pc.expected_score).to be_within(0.001).of(3.685)
|
388
|
+
expect(pc.new_rating).to be_within(0.5).of(1984)
|
389
389
|
end
|
390
390
|
end
|
391
391
|
|
@@ -534,9 +534,9 @@ module ICU
|
|
534
534
|
].each do |item|
|
535
535
|
num, expected_score, new_rating = item
|
536
536
|
p = @t.player(num)
|
537
|
-
p.expected_score.
|
538
|
-
p.new_rating.
|
539
|
-
p.results.inject(p.rating){ |t,r| t + r.rating_change }.
|
537
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
538
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
539
|
+
expect(p.results.inject(p.rating){ |t,r| t + r.rating_change }).to be_within(0.5).of(new_rating)
|
540
540
|
end
|
541
541
|
end
|
542
542
|
|
@@ -547,15 +547,15 @@ module ICU
|
|
547
547
|
].each do |item|
|
548
548
|
num, expected_score, new_rating = item
|
549
549
|
p = @t.player(num)
|
550
|
-
p.expected_score.
|
551
|
-
p.new_rating.
|
550
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
551
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
552
552
|
end
|
553
553
|
end
|
554
554
|
|
555
555
|
it "players who didn't play any rated games should not change their rating" do
|
556
556
|
p = @t.player(15)
|
557
|
-
p.expected_score.
|
558
|
-
p.new_rating.
|
557
|
+
expect(p.expected_score).to eq(0)
|
558
|
+
expect(p.new_rating).to eq(p.rating)
|
559
559
|
end
|
560
560
|
end
|
561
561
|
|
@@ -608,8 +608,8 @@ module ICU
|
|
608
608
|
].each do |item|
|
609
609
|
num, expected_score, new_rating = item
|
610
610
|
p = @t.player(num)
|
611
|
-
p.expected_score.
|
612
|
-
p.new_rating.
|
611
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
612
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
613
613
|
end
|
614
614
|
end
|
615
615
|
end
|
@@ -660,10 +660,10 @@ module ICU
|
|
660
660
|
].each do |item|
|
661
661
|
num, score, expected_score, new_rating, bonus = item
|
662
662
|
p = @t.player(num)
|
663
|
-
p.score.
|
664
|
-
p.expected_score.
|
665
|
-
p.new_rating.
|
666
|
-
p.bonus.
|
663
|
+
expect(p.score).to eq(score)
|
664
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
665
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
666
|
+
expect(p.bonus).to eq(bonus)
|
667
667
|
end
|
668
668
|
end
|
669
669
|
|
@@ -679,11 +679,11 @@ module ICU
|
|
679
679
|
num, pre_bonus = item
|
680
680
|
p = @t.player(num)
|
681
681
|
if pre_bonus
|
682
|
-
p.pb_rating.
|
683
|
-
p.pb_performance.
|
682
|
+
expect(p.pb_rating).to be_kind_of Fixnum
|
683
|
+
expect(p.pb_performance).to be_kind_of Fixnum
|
684
684
|
else
|
685
|
-
p.pb_rating.
|
686
|
-
p.pb_performance.
|
685
|
+
expect(p.pb_rating).to be_nil
|
686
|
+
expect(p.pb_performance).to be_nil
|
687
687
|
end
|
688
688
|
end
|
689
689
|
end
|
@@ -733,22 +733,22 @@ module ICU
|
|
733
733
|
].each do |item|
|
734
734
|
num, score, expected_score, performance = item
|
735
735
|
p = @t.player(num)
|
736
|
-
p.score.
|
737
|
-
p.expected_score.
|
738
|
-
p.performance.
|
736
|
+
expect(p.score).to eq(score)
|
737
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
738
|
+
expect(p.performance).to be_within(0.5).of(performance)
|
739
739
|
if num == 1
|
740
|
-
p.new_rating.
|
741
|
-
p.bonus.
|
740
|
+
expect(p.new_rating).to be_within(0.5).of(1836)
|
741
|
+
expect(p.bonus).to eq(71)
|
742
742
|
else
|
743
|
-
p.new_rating.
|
743
|
+
expect(p.new_rating).to eq(p.rating)
|
744
744
|
end
|
745
745
|
end
|
746
746
|
end
|
747
747
|
|
748
748
|
it "players eligible for a bonus should have pre-bonus data" do
|
749
749
|
p = @t.player(1)
|
750
|
-
p.pb_rating.
|
751
|
-
p.pb_performance.
|
750
|
+
expect(p.pb_rating).to be_kind_of Fixnum
|
751
|
+
expect(p.pb_performance).to be_kind_of Fixnum
|
752
752
|
end
|
753
753
|
end
|
754
754
|
|
@@ -798,11 +798,11 @@ module ICU
|
|
798
798
|
].each do |item|
|
799
799
|
num, score, expected_score, performance, new_rating, bonus = item
|
800
800
|
p = @t.player(num)
|
801
|
-
p.score.
|
802
|
-
p.bonus.
|
803
|
-
p.performance.
|
804
|
-
p.expected_score.
|
805
|
-
p.new_rating.
|
801
|
+
expect(p.score).to eq(score)
|
802
|
+
expect(p.bonus).to eq(bonus) if bonus
|
803
|
+
expect(p.performance).to be_within(0.5).of(performance)
|
804
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
805
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
806
806
|
end
|
807
807
|
end
|
808
808
|
end
|
@@ -858,11 +858,11 @@ module ICU
|
|
858
858
|
@m.each do |item|
|
859
859
|
num, score, expected_score, performance, new_rating, bonus = item
|
860
860
|
p = @t.player(num)
|
861
|
-
p.score.
|
862
|
-
p.bonus.
|
863
|
-
p.performance.
|
864
|
-
p.expected_score.
|
865
|
-
p.new_rating.
|
861
|
+
expect(p.score).to eq(score)
|
862
|
+
expect(p.bonus).to eq(bonus) if bonus
|
863
|
+
expect(p.performance).to be_within(num == 2 ? 0.6 : 0.5).of(performance)
|
864
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
865
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
866
866
|
end
|
867
867
|
end
|
868
868
|
|
@@ -871,11 +871,11 @@ module ICU
|
|
871
871
|
@m.each do |item|
|
872
872
|
num, score, expected_score, performance, new_rating, bonus = item
|
873
873
|
p = @t.player(num)
|
874
|
-
p.score.
|
875
|
-
p.bonus.
|
876
|
-
p.performance.
|
877
|
-
p.expected_score.
|
878
|
-
p.new_rating.
|
874
|
+
expect(p.score).to eq(score)
|
875
|
+
expect(p.bonus).to eq(bonus) if bonus
|
876
|
+
expect(p.performance).to be_within(num == 2 ? 0.6 : 0.5).of(performance)
|
877
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
878
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
879
879
|
end
|
880
880
|
end
|
881
881
|
|
@@ -885,11 +885,11 @@ module ICU
|
|
885
885
|
@m.each do |item|
|
886
886
|
num, score, expected_score, performance, new_rating, bonus = item
|
887
887
|
p = @t.player(num)
|
888
|
-
p.score.
|
889
|
-
p.bonus.
|
890
|
-
p.performance.
|
891
|
-
p.expected_score.
|
892
|
-
p.new_rating.
|
888
|
+
expect(p.score).to eq(score)
|
889
|
+
expect(p.bonus).to eq(0) if bonus
|
890
|
+
expect(p.performance).not_to be_within(1.0).of(performance)
|
891
|
+
expect(p.expected_score).not_to be_within(0.01).of(expected_score)
|
892
|
+
expect(p.new_rating).not_to be_within(1.0).of(new_rating)
|
893
893
|
end
|
894
894
|
end
|
895
895
|
end
|
@@ -928,16 +928,16 @@ module ICU
|
|
928
928
|
].each do |item|
|
929
929
|
num, expected_score, new_rating = item
|
930
930
|
p = @t.player(num)
|
931
|
-
p.expected_score.
|
932
|
-
p.new_rating.
|
931
|
+
expect(p.expected_score).to be_within(0.01).of(expected_score)
|
932
|
+
expect(p.new_rating).to be_within(0.5).of(new_rating)
|
933
933
|
end
|
934
934
|
end
|
935
935
|
|
936
936
|
it "should not rate players that have no rateable games" do
|
937
937
|
[4, 5, 6].each do |num|
|
938
938
|
p = @t.player(num)
|
939
|
-
p.expected_score.
|
940
|
-
p.new_rating.
|
939
|
+
expect(p.expected_score).to eq(0.0)
|
940
|
+
expect(p.new_rating).to be_nil
|
941
941
|
end
|
942
942
|
end
|
943
943
|
end
|
@@ -1006,19 +1006,19 @@ module ICU
|
|
1006
1006
|
|
1007
1007
|
it "should behave like the Access system" do
|
1008
1008
|
@t.rate!
|
1009
|
-
@p1.new_rating.
|
1010
|
-
@p1.expected_score.
|
1011
|
-
@p1.bonus.
|
1012
|
-
@p2.new_rating.
|
1009
|
+
expect(@p1.new_rating).to be_within(0.5).of(1511)
|
1010
|
+
expect(@p1.expected_score).to be_within(0.001).of(2.868)
|
1011
|
+
expect(@p1.bonus).to eq(0)
|
1012
|
+
expect(@p2.new_rating).to be_within(0.5).of(1705)
|
1013
1013
|
end
|
1014
1014
|
|
1015
1015
|
it "should behave like ratings.ciu.ie" do
|
1016
1016
|
@p1.instance_eval { @kfactor = 32 }
|
1017
1017
|
@t.rate!
|
1018
|
-
@p1.new_rating.
|
1019
|
-
@p1.expected_score.
|
1020
|
-
@p1.bonus.
|
1021
|
-
@p2.new_rating.
|
1018
|
+
expect(@p1.new_rating).to be_within(0.5).of(1603)
|
1019
|
+
expect(@p1.expected_score).to be_within(0.001).of(2.868)
|
1020
|
+
expect(@p1.bonus).to be_within(1).of(63)
|
1021
|
+
expect(@p2.new_rating).to be_within(0.5).of(1722)
|
1022
1022
|
end
|
1023
1023
|
end
|
1024
1024
|
|
@@ -1222,69 +1222,69 @@ module ICU
|
|
1222
1222
|
end
|
1223
1223
|
|
1224
1224
|
it "should be setup properly" do
|
1225
|
-
@p.desc.
|
1226
|
-
@o1.desc.
|
1227
|
-
@o2.desc.
|
1228
|
-
@o3.desc.
|
1229
|
-
@o4.desc.
|
1230
|
-
@o5.desc.
|
1231
|
-
@o6.desc.
|
1225
|
+
expect(@p.desc).to eq("Jonathon Peoples")
|
1226
|
+
expect(@o1.desc).to eq("Ross Beatty")
|
1227
|
+
expect(@o2.desc).to eq("Shane Melaugh")
|
1228
|
+
expect(@o3.desc).to eq("Piotr Baczkowski")
|
1229
|
+
expect(@o4.desc).to eq("Tom McGrath")
|
1230
|
+
expect(@o5.desc).to eq("Joe McEntegert")
|
1231
|
+
expect(@o6.desc).to eq("David Halpenny")
|
1232
1232
|
|
1233
|
-
@p.type.
|
1234
|
-
@o1.type.
|
1235
|
-
@o2.type.
|
1236
|
-
@o3.type.
|
1237
|
-
@o4.type.
|
1238
|
-
@o5.type.
|
1239
|
-
@o6.type.
|
1233
|
+
expect(@p.type).to eq(:unrated)
|
1234
|
+
expect(@o1.type).to eq(:provisional)
|
1235
|
+
expect(@o2.type).to eq(:rated)
|
1236
|
+
expect(@o3.type).to eq(:provisional)
|
1237
|
+
expect(@o4.type).to eq(:rated)
|
1238
|
+
expect(@o5.type).to eq(:unrated)
|
1239
|
+
expect(@o6.type).to eq(:provisional)
|
1240
1240
|
|
1241
|
-
@o2.rating.
|
1242
|
-
@o4.rating.
|
1241
|
+
expect(@o2.rating).to eq(683)
|
1242
|
+
expect(@o4.rating).to eq(1058)
|
1243
1243
|
|
1244
|
-
@t.iterations1.
|
1245
|
-
@t.iterations2.
|
1244
|
+
expect(@t.iterations1).to be_nil
|
1245
|
+
expect(@t.iterations2).to be_nil
|
1246
1246
|
end
|
1247
1247
|
|
1248
1248
|
it "should produce inconsistent results with original algorithm" do
|
1249
1249
|
@t.rate!
|
1250
1250
|
|
1251
|
-
@p.new_rating.
|
1251
|
+
expect(@p.new_rating).to be_within(0.5).of(763) # the original calculation
|
1252
1252
|
|
1253
|
-
@o1.new_rating.
|
1254
|
-
@o2.bonus.
|
1255
|
-
@o3.new_rating.
|
1256
|
-
@o4.bonus.
|
1257
|
-
@o5.new_rating.
|
1258
|
-
@o6.new_rating.
|
1253
|
+
expect(@o1.new_rating).to eq(@o1.performance)
|
1254
|
+
expect(@o2.bonus).to eq(0)
|
1255
|
+
expect(@o3.new_rating).to eq(@o3.performance)
|
1256
|
+
expect(@o4.bonus).to eq(0)
|
1257
|
+
expect(@o5.new_rating).to eq(@o5.performance)
|
1258
|
+
expect(@o6.new_rating).to eq(@o6.performance)
|
1259
1259
|
|
1260
1260
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.new_rating(:opponent) }
|
1261
1261
|
|
1262
1262
|
average_of_ratings = ratings.inject(0.0){ |m,r| m = m + r } / 6.0
|
1263
|
-
average_of_ratings.
|
1263
|
+
expect(average_of_ratings).not_to be_within(0.5).of(@p.new_rating)
|
1264
1264
|
|
1265
|
-
@t.iterations1.
|
1266
|
-
@t.iterations2.
|
1265
|
+
expect(@t.iterations1).to be > 1
|
1266
|
+
expect(@t.iterations2).to eq(1)
|
1267
1267
|
end
|
1268
1268
|
|
1269
1269
|
it "should produce consistent results with version 1 algorithm" do
|
1270
1270
|
@t.rate!(version: 1)
|
1271
1271
|
|
1272
|
-
@p.new_rating.
|
1272
|
+
expect(@p.new_rating).not_to be_within(0.5).of(763) # the new calculation is different
|
1273
1273
|
|
1274
|
-
@o1.new_rating.
|
1275
|
-
@o2.bonus.
|
1276
|
-
@o3.new_rating.
|
1277
|
-
@o4.bonus.
|
1278
|
-
@o5.new_rating.
|
1279
|
-
@o6.new_rating.
|
1274
|
+
expect(@o1.new_rating).to eq(@o1.performance)
|
1275
|
+
expect(@o2.bonus).to eq(0)
|
1276
|
+
expect(@o3.new_rating).to eq(@o3.performance)
|
1277
|
+
expect(@o4.bonus).to eq(0)
|
1278
|
+
expect(@o5.new_rating).to eq(@o5.performance)
|
1279
|
+
expect(@o6.new_rating).to eq(@o6.performance)
|
1280
1280
|
|
1281
1281
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.new_rating(:opponent) }
|
1282
1282
|
|
1283
1283
|
average_of_ratings = ratings.inject(0.0){ |m,r| m = m + r } / 6.0
|
1284
|
-
average_of_ratings.
|
1284
|
+
expect(average_of_ratings).to be_within(0.5).of(@p.new_rating)
|
1285
1285
|
|
1286
|
-
@t.iterations1.
|
1287
|
-
@t.iterations2.
|
1286
|
+
expect(@t.iterations1).to be > 1
|
1287
|
+
expect(@t.iterations2).to be > 1
|
1288
1288
|
end
|
1289
1289
|
end
|
1290
1290
|
|
@@ -1998,111 +1998,111 @@ module ICU
|
|
1998
1998
|
end
|
1999
1999
|
|
2000
2000
|
it "should be setup properly" do
|
2001
|
-
@p.desc.
|
2002
|
-
@o1.desc.
|
2003
|
-
@o2.desc.
|
2004
|
-
@o3.desc.
|
2005
|
-
@o4.desc.
|
2006
|
-
@o5.desc.
|
2007
|
-
@o6.desc.
|
2008
|
-
|
2009
|
-
@p.type.
|
2010
|
-
@o1.type.
|
2011
|
-
@o2.type.
|
2012
|
-
@o3.type.
|
2013
|
-
@o4.type.
|
2014
|
-
@o5.type.
|
2015
|
-
@o6.type.
|
2016
|
-
|
2017
|
-
@o1.rating.
|
2018
|
-
@o2.rating.
|
2019
|
-
@o3.rating.
|
2020
|
-
@o4.rating.
|
2021
|
-
@o5.rating.
|
2022
|
-
@o6.rating.
|
2023
|
-
|
2024
|
-
@t.iterations1.
|
2025
|
-
@t.iterations2.
|
2001
|
+
expect(@p.desc).to eq("Sasha-Ettore Faleschini")
|
2002
|
+
expect(@o1.desc).to eq("John P. Dunne")
|
2003
|
+
expect(@o2.desc).to eq("Jack Fitzgerald")
|
2004
|
+
expect(@o3.desc).to eq("Mikolaj Glegolski")
|
2005
|
+
expect(@o4.desc).to eq("Daniel Boland")
|
2006
|
+
expect(@o5.desc).to eq("Noel Keating")
|
2007
|
+
expect(@o6.desc).to eq("Cathal Minnock")
|
2008
|
+
|
2009
|
+
expect(@p.type).to eq(:unrated)
|
2010
|
+
expect(@o1.type).to eq(:rated)
|
2011
|
+
expect(@o2.type).to eq(:rated)
|
2012
|
+
expect(@o3.type).to eq(:rated)
|
2013
|
+
expect(@o4.type).to eq(:rated)
|
2014
|
+
expect(@o5.type).to eq(:rated)
|
2015
|
+
expect(@o6.type).to eq(:rated)
|
2016
|
+
|
2017
|
+
expect(@o1.rating).to eq(946)
|
2018
|
+
expect(@o2.rating).to eq(913)
|
2019
|
+
expect(@o3.rating).to eq(841)
|
2020
|
+
expect(@o4.rating).to eq(793)
|
2021
|
+
expect(@o5.rating).to eq(667)
|
2022
|
+
expect(@o6.rating).to eq(917)
|
2023
|
+
|
2024
|
+
expect(@t.iterations1).to be_nil
|
2025
|
+
expect(@t.iterations2).to be_nil
|
2026
2026
|
end
|
2027
2027
|
|
2028
2028
|
it "should produce inconsistent results with original algorithm" do
|
2029
2029
|
@t.rate!
|
2030
2030
|
|
2031
|
-
@p.new_rating.
|
2031
|
+
expect(@p.new_rating).to eq(@p.performance)
|
2032
2032
|
|
2033
|
-
@o1.bonus.
|
2034
|
-
@o2.bonus.
|
2035
|
-
@o3.bonus.
|
2036
|
-
@o4.bonus.
|
2037
|
-
@o5.bonus.
|
2038
|
-
@o6.bonus.
|
2033
|
+
expect(@o1.bonus).to eq(16)
|
2034
|
+
expect(@o2.bonus).to eq(0)
|
2035
|
+
expect(@o3.bonus).to eq(0)
|
2036
|
+
expect(@o4.bonus).to eq(0)
|
2037
|
+
expect(@o5.bonus).to eq(0)
|
2038
|
+
expect(@o6.bonus).to eq(0)
|
2039
2039
|
|
2040
2040
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.bonus == 0 ? o.rating : o.new_rating }
|
2041
2041
|
|
2042
2042
|
performance = ratings.inject(0.0){ |m,r| m = m + r } / 6.0 - 400.0 / 3.0
|
2043
|
-
performance.
|
2043
|
+
expect(performance).not_to be_within(0.5).of(@p.new_rating)
|
2044
2044
|
|
2045
|
-
@t.iterations1.
|
2046
|
-
@t.iterations2.
|
2045
|
+
expect(@t.iterations1).to be > 1
|
2046
|
+
expect(@t.iterations2).to eq(1)
|
2047
2047
|
end
|
2048
2048
|
|
2049
2049
|
it "should produce inconsistent results with version 1 algorithm" do
|
2050
2050
|
@t.rate!(version: 1)
|
2051
2051
|
|
2052
|
-
@p.new_rating.
|
2052
|
+
expect(@p.new_rating).to eq(@p.performance)
|
2053
2053
|
|
2054
|
-
@o1.bonus.
|
2055
|
-
@o2.bonus.
|
2056
|
-
@o3.bonus.
|
2057
|
-
@o4.bonus.
|
2058
|
-
@o5.bonus.
|
2059
|
-
@o6.bonus.
|
2054
|
+
expect(@o1.bonus).to eq(16)
|
2055
|
+
expect(@o2.bonus).to eq(0)
|
2056
|
+
expect(@o3.bonus).to eq(0)
|
2057
|
+
expect(@o4.bonus).to eq(0)
|
2058
|
+
expect(@o5.bonus).to eq(0)
|
2059
|
+
expect(@o6.bonus).to eq(0)
|
2060
2060
|
|
2061
2061
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.bonus == 0 ? o.rating : o.new_rating }
|
2062
2062
|
|
2063
2063
|
performance = ratings.inject(0.0){ |m,r| m = m + r } / 6.0 - 400.0 / 3.0
|
2064
|
-
performance.
|
2064
|
+
expect(performance).not_to be_within(0.5).of(@p.new_rating)
|
2065
2065
|
|
2066
|
-
@t.iterations1.
|
2067
|
-
@t.iterations2.
|
2066
|
+
expect(@t.iterations1).to be > 1
|
2067
|
+
expect(@t.iterations2).to be > 1
|
2068
2068
|
end
|
2069
2069
|
|
2070
2070
|
it "should produce consistent results with version 2 algorithm" do
|
2071
2071
|
@t.rate!(version: 2)
|
2072
2072
|
|
2073
|
-
@o1.bonus.
|
2074
|
-
@o2.bonus.
|
2075
|
-
@o3.bonus.
|
2076
|
-
@o4.bonus.
|
2077
|
-
@o5.bonus.
|
2078
|
-
@o6.bonus.
|
2073
|
+
expect(@o1.bonus).to eq(0) # no bonus this time because it comes from 2nd phase
|
2074
|
+
expect(@o2.bonus).to eq(0)
|
2075
|
+
expect(@o3.bonus).to eq(0)
|
2076
|
+
expect(@o4.bonus).to eq(0)
|
2077
|
+
expect(@o5.bonus).to eq(0)
|
2078
|
+
expect(@o6.bonus).to eq(0)
|
2079
2079
|
|
2080
2080
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.bonus == 0 ? o.rating : o.new_rating }
|
2081
2081
|
|
2082
2082
|
performance = ratings.inject(0.0){ |m,r| m = m + r } / 6.0 - 400.0 / 3.0
|
2083
|
-
performance.
|
2083
|
+
expect(performance).to be_within(0.5).of(@p.new_rating)
|
2084
2084
|
|
2085
|
-
@t.iterations1.
|
2086
|
-
@t.iterations2.
|
2085
|
+
expect(@t.iterations1).to be > 1
|
2086
|
+
expect(@t.iterations2).to be > 1
|
2087
2087
|
end
|
2088
2088
|
|
2089
2089
|
it "should produce consistent results with version 3 algorithm" do
|
2090
2090
|
@t.rate!(version: 3)
|
2091
2091
|
|
2092
|
-
@o1.bonus.
|
2093
|
-
@o2.bonus.
|
2094
|
-
@o3.bonus.
|
2095
|
-
@o4.bonus.
|
2096
|
-
@o5.bonus.
|
2097
|
-
@o6.bonus.
|
2092
|
+
expect(@o1.bonus).to eq(0) # no bonus this time because it comes from 2nd phase
|
2093
|
+
expect(@o2.bonus).to eq(0)
|
2094
|
+
expect(@o3.bonus).to eq(0)
|
2095
|
+
expect(@o4.bonus).to eq(0)
|
2096
|
+
expect(@o5.bonus).to eq(0)
|
2097
|
+
expect(@o6.bonus).to eq(0)
|
2098
2098
|
|
2099
2099
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.bonus == 0 ? o.rating : o.new_rating }
|
2100
2100
|
|
2101
2101
|
performance = ratings.inject(0.0){ |m,r| m = m + r } / 6.0 - 400.0 / 3.0
|
2102
|
-
performance.
|
2102
|
+
expect(performance).to be_within(0.5).of(@p.new_rating)
|
2103
2103
|
|
2104
|
-
@t.iterations1.
|
2105
|
-
@t.iterations2.
|
2104
|
+
expect(@t.iterations1).to be > 1
|
2105
|
+
expect(@t.iterations2).to be > 1
|
2106
2106
|
end
|
2107
2107
|
end
|
2108
2108
|
|
@@ -2210,50 +2210,50 @@ module ICU
|
|
2210
2210
|
end
|
2211
2211
|
|
2212
2212
|
it "should be setup properly" do
|
2213
|
-
@p.desc.
|
2214
|
-
@o1.desc.
|
2215
|
-
@o2.desc.
|
2216
|
-
@o3.desc.
|
2217
|
-
@o4.desc.
|
2218
|
-
@o5.desc.
|
2219
|
-
@o6.desc.
|
2220
|
-
|
2221
|
-
@p.type.
|
2222
|
-
@o1.type.
|
2223
|
-
@o2.type.
|
2224
|
-
@o3.type.
|
2225
|
-
@o4.type.
|
2226
|
-
@o5.type.
|
2227
|
-
@o6.type.
|
2228
|
-
|
2229
|
-
@o1.rating.
|
2230
|
-
@o2.
|
2231
|
-
@o3.rating.
|
2232
|
-
@o4.rating.
|
2233
|
-
@o5.rating.
|
2234
|
-
@o6.rating.
|
2235
|
-
|
2236
|
-
@t.iterations1.
|
2237
|
-
@t.iterations2.
|
2213
|
+
expect(@p.desc).to eq("Deirdre Turner")
|
2214
|
+
expect(@o1.desc).to eq("John P. Dunne")
|
2215
|
+
expect(@o2.desc).to eq("Jordan O'Sullivan")
|
2216
|
+
expect(@o3.desc).to eq("Ruairi Freeman")
|
2217
|
+
expect(@o4.desc).to eq("Joe Cronin")
|
2218
|
+
expect(@o5.desc).to eq("Jeffrey Alfred")
|
2219
|
+
expect(@o6.desc).to eq("Roisin MacNamee")
|
2220
|
+
|
2221
|
+
expect(@p.type).to eq(:unrated)
|
2222
|
+
expect(@o1.type).to eq(:rated)
|
2223
|
+
expect(@o2.type).to eq(:unrated)
|
2224
|
+
expect(@o3.type).to eq(:rated)
|
2225
|
+
expect(@o4.type).to eq(:rated)
|
2226
|
+
expect(@o5.type).to eq(:rated)
|
2227
|
+
expect(@o6.type).to eq(:provisional)
|
2228
|
+
|
2229
|
+
expect(@o1.rating).to eq(980)
|
2230
|
+
expect(@o2).not_to respond_to(:rating)
|
2231
|
+
expect(@o3.rating).to eq(537)
|
2232
|
+
expect(@o4.rating).to eq(682)
|
2233
|
+
expect(@o5.rating).to eq(1320)
|
2234
|
+
expect(@o6.rating).to eq(460)
|
2235
|
+
|
2236
|
+
expect(@t.iterations1).to be_nil
|
2237
|
+
expect(@t.iterations2).to be_nil
|
2238
2238
|
end
|
2239
2239
|
|
2240
2240
|
it "should produce consistent results with version 2 algorithm" do
|
2241
2241
|
@t.rate!(version: 2)
|
2242
2242
|
|
2243
|
-
@p.new_rating.
|
2243
|
+
expect(@p.new_rating).to eq(@p.performance)
|
2244
2244
|
|
2245
|
-
@o1.bonus.
|
2246
|
-
@o3.bonus.
|
2247
|
-
@o4.bonus.
|
2248
|
-
@o5.bonus.
|
2245
|
+
expect(@o1.bonus).to eq(23)
|
2246
|
+
expect(@o3.bonus).to eq(0)
|
2247
|
+
expect(@o4.bonus).to eq(0)
|
2248
|
+
expect(@o5.bonus).to eq(0)
|
2249
2249
|
|
2250
2250
|
ratings = [@o1, @o2, @o3, @o4, @o5, @o6].map { |o| o.new_rating(:opponent) }
|
2251
2251
|
|
2252
2252
|
performance = ratings.inject(0.0){ |m,r| m = m + r } / 6.0
|
2253
|
-
performance.
|
2253
|
+
expect(performance).to be_within(0.1).of(@p.new_rating)
|
2254
2254
|
|
2255
|
-
@t.iterations1.
|
2256
|
-
@t.iterations2.
|
2255
|
+
expect(@t.iterations1).to be > 1
|
2256
|
+
expect(@t.iterations2).to be > 1
|
2257
2257
|
end
|
2258
2258
|
end
|
2259
2259
|
|
@@ -2393,56 +2393,56 @@ module ICU
|
|
2393
2393
|
end
|
2394
2394
|
|
2395
2395
|
it "should be setup properly" do
|
2396
|
-
@p.desc.
|
2397
|
-
@o1.desc.
|
2398
|
-
@o2.desc.
|
2399
|
-
@o3.desc.
|
2400
|
-
@o4.desc.
|
2401
|
-
@o5.desc.
|
2402
|
-
@o6.desc.
|
2403
|
-
|
2404
|
-
@p.type.
|
2405
|
-
@o1.type.
|
2406
|
-
@o2.type.
|
2407
|
-
@o3.type.
|
2408
|
-
@o4.type.
|
2409
|
-
@o5.type.
|
2410
|
-
@o6.type.
|
2411
|
-
|
2412
|
-
@p.rating.
|
2413
|
-
@o1.rating.
|
2414
|
-
@o2.rating.
|
2415
|
-
@o3.rating.
|
2416
|
-
@o4.rating.
|
2417
|
-
@o5.rating.
|
2418
|
-
@o6.rating.
|
2419
|
-
|
2420
|
-
@t.iterations1.
|
2421
|
-
@t.iterations2.
|
2396
|
+
expect(@p.desc).to eq("Kieran O'Riordan")
|
2397
|
+
expect(@o1.desc).to eq("Jonathan Kiely")
|
2398
|
+
expect(@o2.desc).to eq("Donal O'Hallahan")
|
2399
|
+
expect(@o3.desc).to eq("Arnaud, Aoustin")
|
2400
|
+
expect(@o4.desc).to eq("Ronan Magee")
|
2401
|
+
expect(@o5.desc).to eq("Barry Foran")
|
2402
|
+
expect(@o6.desc).to eq("Henk De Jonge")
|
2403
|
+
|
2404
|
+
expect(@p.type).to eq(:rated)
|
2405
|
+
expect(@o1.type).to eq(:rated)
|
2406
|
+
expect(@o2.type).to eq(:rated)
|
2407
|
+
expect(@o3.type).to eq(:rated)
|
2408
|
+
expect(@o4.type).to eq(:rated)
|
2409
|
+
expect(@o5.type).to eq(:rated)
|
2410
|
+
expect(@o6.type).to eq(:rated)
|
2411
|
+
|
2412
|
+
expect(@p.rating).to eq(1883)
|
2413
|
+
expect(@o1.rating).to eq(1113)
|
2414
|
+
expect(@o2.rating).to eq(1465)
|
2415
|
+
expect(@o3.rating).to eq(1984)
|
2416
|
+
expect(@o4.rating).to eq(1957)
|
2417
|
+
expect(@o5.rating).to eq(1417)
|
2418
|
+
expect(@o6.rating).to eq(1977)
|
2419
|
+
|
2420
|
+
expect(@t.iterations1).to be_nil
|
2421
|
+
expect(@t.iterations2).to be_nil
|
2422
2422
|
end
|
2423
2423
|
|
2424
2424
|
it "player should not get a bonus because his pre-bonus performance is lower than his post-bonus rating" do
|
2425
2425
|
@t.rate!(version: 2)
|
2426
2426
|
|
2427
|
-
@p.new_rating.
|
2427
|
+
expect(@p.new_rating).to be_within(0.5).of(1924)
|
2428
2428
|
|
2429
|
-
@p.bonus.
|
2430
|
-
@o1.bonus.
|
2431
|
-
@o2.bonus.
|
2432
|
-
@o3.bonus.
|
2433
|
-
@o4.bonus.
|
2434
|
-
@o5.bonus.
|
2435
|
-
@o6.bonus.
|
2429
|
+
expect(@p.bonus).to eq(0)
|
2430
|
+
expect(@o1.bonus).to eq(0)
|
2431
|
+
expect(@o2.bonus).to eq(0)
|
2432
|
+
expect(@o3.bonus).to eq(0)
|
2433
|
+
expect(@o4.bonus).to eq(0)
|
2434
|
+
expect(@o5.bonus).to eq(0)
|
2435
|
+
expect(@o6.bonus).to eq(0)
|
2436
2436
|
|
2437
2437
|
threshold = @p.rating + 32 + 3 * (@p.results.size - 4)
|
2438
2438
|
|
2439
2439
|
# He would have got a bonus ...
|
2440
2440
|
pre_cap_bonus = ((@p.pb_rating - threshold).round * 1.25).round
|
2441
|
-
pre_cap_bonus.
|
2441
|
+
expect(pre_cap_bonus).to be > 0
|
2442
2442
|
|
2443
2443
|
# ... if it wasn't for his low performance.
|
2444
2444
|
post_cap_bonus = @p.pb_performance - @p.pb_rating
|
2445
|
-
post_cap_bonus.
|
2445
|
+
expect(post_cap_bonus).to be < 0
|
2446
2446
|
end
|
2447
2447
|
end
|
2448
2448
|
|
@@ -2614,11 +2614,11 @@ module ICU
|
|
2614
2614
|
end
|
2615
2615
|
|
2616
2616
|
it "should not converge with version 2 settings" do
|
2617
|
-
|
2617
|
+
expect { @t.rate!(version: 2) }.to raise_error(/performance rating estimation did not converge/)
|
2618
2618
|
end
|
2619
2619
|
|
2620
2620
|
it "should converge with version 3 settings (higher maximum number of iterations)" do
|
2621
|
-
|
2621
|
+
expect { @t.rate!(version: 3) }.not_to raise_error
|
2622
2622
|
end
|
2623
2623
|
end
|
2624
2624
|
end
|