1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/cases/tests_database.rb
Carlhuda 24ab5665b2 Revert "Fix test load paths for those not using bundler"
This reverts commit eec2d301d4.

This commit broke tests. You cannot have a file called "bundler" on the load path.
2010-02-23 17:31:17 -08:00

35 lines
813 B
Ruby

require 'logger'
$:.unshift(File.dirname(__FILE__) + '/../../../activerecord/lib')
require 'active_record'
module ActiveModel
module TestsDatabase
mattr_accessor :connected
def self.included(base)
unless self.connected
setup_connection
setup_schema
end
base.send :include, ActiveRecord::TestFixtures
end
def self.setup_schema
original, $stdout = $stdout, StringIO.new
load(SCHEMA_FILE)
ensure
$stdout = original
self.connected = true
end
def self.setup_connection
defaults = { :database => ':memory:' }
adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'
options = defaults.merge :adapter => adapter, :timeout => 500
ActiveRecord::Base.establish_connection(options)
end
end
end