icu_ratings 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/icu_ratings/player.rb +1 -0
- data/spec/player_spec.rb +7 -0
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/icu_ratings/player.rb
CHANGED
@@ -191,6 +191,7 @@ method.
|
|
191
191
|
|
192
192
|
# Calculate a K-factor according to ICU rules.
|
193
193
|
def self.kfactor(args)
|
194
|
+
%w{rating start dob joined}.each { |a| raise "missing #{a} for K-factor calculation" unless args[a.to_sym] }
|
194
195
|
case
|
195
196
|
when args[:rating] >= 2100 then
|
196
197
|
16
|
data/spec/player_spec.rb
CHANGED
@@ -158,6 +158,13 @@ module ICU
|
|
158
158
|
it "should otherwise return 24" do
|
159
159
|
ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-01-01').should == 24
|
160
160
|
end
|
161
|
+
|
162
|
+
it "should throw an exception if required information is missing" do
|
163
|
+
lambda { ICU::RatedPlayer.kfactor(:start => '2010-07-10', :dob => '1989-01-01', :joined => '2002-01-01') }.should raise_error(/missing.*rating/)
|
164
|
+
lambda { ICU::RatedPlayer.kfactor(:rating => 2000, :dob => '1989-01-01', :joined => '2002-01-01') }.should raise_error(/missing.*start/)
|
165
|
+
lambda { ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :joined => '2002-01-01') }.should raise_error(/missing.*dob/)
|
166
|
+
lambda { ICU::RatedPlayer.kfactor(:rating => 2000, :start => '2010-07-10', :dob => '1989-01-01') }.should raise_error(/missing.*join/)
|
167
|
+
end
|
161
168
|
end
|
162
169
|
|
163
170
|
context "Rdoc examples" do
|