Sha256: 4b4688412a14f240a755c2e9c8718c5e1e8a0b08bbcac332eb368d9b14bf98b8

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

require 'active_record'
require 'wlog/commands/innit_db'

# make the testing database in the relative path
def make_testing_db(dbname)
  current = standard_db_path(dbname)
  ActiveRecord::Base.configurations = {
    'testing' => {
      :adapter => 'sqlite3',
      :database => current,
      :pool => 5,
      :timeout => 5000
    }
  }
  ActiveRecord::Base.establish_connection(:testing)
  setup_db
end

def close_testing_db
  ActiveRecord::Base.connection.close
end

# make the tables, and perform possible migrations
def setup_db
  ActiveRecord::Migration.verbose = false
  ActiveRecord::Migration.run(MakeSchemaMigration)

  InnitDb.new.execute_migrations!
end

def standard_db_path(dbname)
  "#{File.expand_path File.dirname(__FILE__)}/#{dbname}"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlog-1.2.2 spec/make_db.rb