2010-02-26 04:53:30 +01:00
|
|
|
require 'pathname'
|
2010-07-06 18:40:02 +02:00
|
|
|
test_dir = Pathname.new File.dirname(__FILE__)
|
|
|
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
|
|
|
|
|
|
require "fileutils"
|
|
|
|
require "rubygems"
|
|
|
|
|
|
|
|
ENV["RAILS_ENV"] = "test"
|
|
|
|
|
|
|
|
require "bundler"
|
|
|
|
Bundler.setup
|
2010-02-26 04:53:30 +01:00
|
|
|
|
2010-09-26 22:51:19 +02:00
|
|
|
require "logger"
|
2010-02-26 04:53:30 +01:00
|
|
|
require "rails"
|
|
|
|
require "rails/test_help"
|
2010-09-26 22:51:19 +02:00
|
|
|
require "active_record"
|
2010-02-26 04:53:30 +01:00
|
|
|
require "active_record/fixtures"
|
2010-03-12 05:52:16 +01:00
|
|
|
require "active_support/test_case"
|
|
|
|
|
|
|
|
require "delorean"
|
2010-02-26 04:53:30 +01:00
|
|
|
require "ruby-debug"
|
|
|
|
|
2010-07-06 18:40:02 +02:00
|
|
|
class MyApplication < Rails::Application ; end
|
|
|
|
adapter = ENV["ARE_DB"] || "sqlite3"
|
|
|
|
|
2010-09-26 22:51:19 +02:00
|
|
|
FileUtils.mkdir_p 'log'
|
2010-03-12 05:52:16 +01:00
|
|
|
ActiveRecord::Base.logger = Logger.new("log/test.log")
|
2010-03-14 02:20:55 +01:00
|
|
|
ActiveRecord::Base.logger.level = Logger::DEBUG
|
2010-07-06 18:40:02 +02:00
|
|
|
ActiveRecord::Base.configurations["test"] = YAML.load(test_dir.join("database.yml").open)[adapter]
|
2010-02-26 04:53:30 +01:00
|
|
|
|
2010-09-27 02:47:27 +02:00
|
|
|
|
2010-09-26 22:51:19 +02:00
|
|
|
require "activerecord-import"
|
2010-09-27 02:47:27 +02:00
|
|
|
ActiveRecord::Base.establish_connection "test"
|
|
|
|
|
2010-09-26 22:51:19 +02:00
|
|
|
|
2010-03-14 02:20:55 +01:00
|
|
|
ActiveSupport::Notifications.subscribe(/active_record.sql/) do |event, _, _, _, hsh|
|
|
|
|
ActiveRecord::Base.logger.info hsh[:sql]
|
|
|
|
end
|
|
|
|
|
2010-03-12 05:52:16 +01:00
|
|
|
require "factory_girl"
|
|
|
|
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each{ |file| require file }
|
|
|
|
|
2010-02-26 04:53:30 +01:00
|
|
|
# Load base/generic schema
|
2010-07-06 18:40:02 +02:00
|
|
|
require test_dir.join("schema/version")
|
|
|
|
require test_dir.join("schema/generic_schema")
|
|
|
|
adapter_schema = test_dir.join("schema/#{adapter}_schema.rb")
|
2010-02-26 04:53:30 +01:00
|
|
|
require adapter_schema if File.exists?(adapter_schema)
|
|
|
|
|
2010-03-12 05:52:16 +01:00
|
|
|
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
|