aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/connections/native_sqlite3_mem/connection.rb
blob: 14e10900d127bfb012e28c1d918844df8236a8ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# This file connects to an in-memory SQLite3 database, which is a very fast way to run the tests.
# The downside is that disconnect from the database results in the database effectively being
# wiped. For this reason, pooled_connections_test.rb is disabled when using an in-memory database.

print "Using native SQLite3 (in memory)\n"
require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")

class SqliteError < StandardError
end

def make_connection(clazz)
  ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database  => ':memory:' } }
  clazz.establish_connection(clazz.name)
end

make_connection(ActiveRecord::Base)
make_connection(Course)