icu_ratings 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :build:
4
4
  :major: 0
5
5
  :minor: 3
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu_ratings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Orr