test/test_reader.rb in sportdb-1.9.8 vs test/test_reader.rb in sportdb-1.9.9
- old
+ new
@@ -7,30 +7,30 @@
# rake -I ./lib test
require 'helper'
-class TestReader < MiniTest::Unit::TestCase
+class TestReader < MiniTest::Test
def setup
WorldDb.delete!
SportDb.delete!
SportDb.read_builtin
end
def test_bl
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
-
- teamreader = TeamReader.new( SportDb.test_data_path )
- teamreader.read( 'at-austria/teams', country_id: at.id )
- leaguereader = LeagueReader.new( SportDb.test_data_path )
- leaguereader.read( 'at-austria/leagues', country_id: at.id )
+ teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
+ teamreader.read()
- gamereader = GameReader.new( SportDb.test_data_path )
+ leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
+ leaguereader.read()
+
## check/fix: is country_id more_attribs needed? why? why not?
- gamereader.read( 'at-austria/2013_14/bl', country_id: at.id )
+ gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
+ gamereader.read()
bl = Event.find_by_key!( 'at.2013/14' )
assert_equal 10, bl.teams.count
assert_equal 36, bl.rounds.count
@@ -39,13 +39,14 @@
def test_game_reader
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
- teamreader = TeamReader.new( SportDb.test_data_path )
- teamreader.read( 'at-austria/teams', country_id: at.id )
- teamreader.read( 'at-austria/teams_2', country_id: at.id )
+ teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
+ teamreader.read()
+ teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
+ teamreader.read()
austria = Team.find_by_key!( 'austria' )
rapid = Team.find_by_key!( 'rapid' )
sturm = Team.find_by_key!( 'sturm' )
@@ -55,24 +56,25 @@
assert_equal 'AUS', austria.code
assert_equal 'RAP', rapid.code
assert_equal 'STU', sturm.code
- leaguereader = LeagueReader.new( SportDb.test_data_path )
- leaguereader.read( 'at-austria/leagues', country_id: at.id )
+ leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
+ leaguereader.read()
at1 = League.find_by_key!( 'at' )
at2 = League.find_by_key!( 'at.2' )
atcup = League.find_by_key!( 'at.cup' )
assert_equal 'Österr. Bundesliga', at1.title
assert_equal 'Österr. Erste Liga', at2.title
assert_equal 'ÖFB Cup', atcup.title
- gamereader = GameReader.new( SportDb.test_data_path )
## check/fix: is country_id more_attribs needed? why? why not?
- gamereader.read( 'at-austria/2013_14/bl', country_id: at.id )
- gamereader.read( 'at-austria/2013_14/el', country_id: at.id )
+ gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
+ gamereader.read()
+ gamereader = TestGameReader.from_file( 'at-austria/2013_14/el', country_id: at.id )
+ gamereader.read()
bl = Event.find_by_key!( 'at.2013/14' )
el = Event.find_by_key!( 'at.2.2013/14' )
assert_equal 10, bl.teams.count