require File.dirname(__FILE__) + '/spec_helper' module ICU class Tournament describe Krause do def check_player(num, first, last, other={}) p = @t.player(num) p.first_name.should == first p.last_name.should == last p.gender.should == other[:gender] p.title.should == other[:title] p.rating.should == other[:rating] p.fed.should == other[:fed] p.id.should == other[:id] p.dob.should == other[:dob] p.rank.should == other[:rank] end def check_results(num, results, points) p = @t.player(num) p.results.size.should == results p.points.should == points end context "a typical tournament" do before(:all) do krause = < 'F', :rating => 1985, :fed => 'IRL', :id => 2501171, :dob => '1964-06-10', :rank => 2) check_player(2, 'Mark', 'Orr', :gender => 'M', :rating => 2258, :fed => 'IRL', :id => 2500035, :dob => '1955-11-09', :rank => 1, :title => 'IM') check_player(3, 'Viktor', 'Bologan', :gender => 'M', :rating => 2663, :fed => 'MDA', :id => 13900048, :dob => '1971-01-01', :rank => 3, :title => 'GM') end it "should have correct results for each player" do check_results(1, 2, 1.0) check_results(2, 2, 2.0) check_results(3, 2, 0.0) end it "the parser should retain comment lines" do comments = < 'F', :rating => 1900, :fed => 'USA', :id => 1234567, :dob => '1928-05-15', :rank => 2) check_player(2, 'Daffy', 'Duck', :gender => 'M', :rating => 2200, :fed => 'IRL', :id => 7654321, :dob => '1937-04-17', :rank => 1, :title => 'IM') check_player(3, 'Mickey', 'Mouse', :gender => 'M', :rating => 2600, :fed => 'USA', :id => 1726354, :dob => '1928-05-15', :rank => 3, :title => 'GM') end it "should have correct results for each player" do check_results(1, 2, 1.0) check_results(2, 2, 2.0) check_results(3, 2, 0.0) end it "the parser should retain comment lines" do @p.comments.should == "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n" end end context "serialisation" do before(:all) do @krause = <