Sha256: 6c9a38a7f7d8c783f80f6aec2fe7afca9261e45417bfa3783907bbc64118903e

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

## $:.unshift(File.dirname(__FILE__))

## minitest setup

# require 'minitest/unit'
require 'minitest/autorun'



require 'pp'


# ruby gems

require 'active_record'

require 'worlddb'
require 'logutils'
require 'logutils/db'   # NB: explict require required for LogDb (not automatic) 
require 'props/db'   ## fix: use textutils/db in the future too ??


## our own code

require 'sportdb'


#######################
#
#  for reuse
#   --- move to sportdb/test.rb ???
#    SportDb.setup_in_memory_db  ??? why? why not??  or
#    SportDb.setup_test_db  - alias ??



def setup_in_memory_db
  # Database Setup & Config

  db_config = {
    adapter:  'sqlite3',
    database: ':memory:'
  }

  pp db_config

  ActiveRecord::Base.logger = Logger.new( STDOUT )
  ## ActiveRecord::Base.colorize_logging = false  - no longer exists - check new api/config setting?

  ## NB: every connect will create a new empty in memory db
  ActiveRecord::Base.establish_connection( db_config )


  ## build schema

  LogDb.create
  ConfDb.create
  TagDb.create
  WorldDb.create
  SportDb.create

  SportDb.read_builtin
end

####
# Models shortcuts

Country    = WorldDb::Model::Country

League     = SportDb::Model::League
Season     = SportDb::Model::Season
Event      = SportDb::Model::Event
Team       = SportDb::Model::Team

Round      = SportDb::Model::Round
Game       = SportDb::Model::Game
GameCursor = SportDb::Model::GameCursor

####
# Reader shortcuts

TeamReader   = SportDb::TeamReader
SeasonReader = SportDb::SeasonReader
LeagueReader = SportDb::LeagueReader
GameReader   = SportDb::GameReader


setup_in_memory_db()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sportdb-1.8.22 test/helper.rb
sportdb-1.8.21 test/helper.rb
sportdb-1.8.20 test/helper.rb