db_populate/test/test_helper.rb

40 lines
855 B
Ruby
Raw Permalink Normal View History

2008-09-16 01:08:50 +00:00
ENV['RAILS_ENV'] = 'test'
2008-10-12 00:05:39 +00:00
require 'rubygems'
2009-11-26 17:02:14 +00:00
begin
gem 'test-unit', '~> 2.0'
rescue Gem::LoadError
require 'test/unit'
end
2008-10-12 00:05:39 +00:00
require 'action_controller'
require 'active_record'
require 'action_view'
2009-11-26 17:45:28 +00:00
require 'mocha'
2008-09-16 01:08:50 +00:00
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
db_adapter = ENV['DB']
# no db passed, try one of these fine config-free DBs before bombing.
db_adapter ||= begin
require 'rubygems'
require 'sqlite'
'sqlite'
rescue MissingSourceFile
begin
require 'sqlite3'
'sqlite3'
rescue MissingSourceFile
end
end
if db_adapter.nil?
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
end
ActiveRecord::Base.establish_connection(config[db_adapter])
load(File.dirname(__FILE__) + "/schema.rb")
require File.dirname(__FILE__) + '/../init.rb'