Updated Rakefile and test_helper to work with more adapters than just sqlite3.
This commit is contained in:
parent
61c1af6520
commit
459aeb6fee
2 changed files with 28 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
|||
ENV["RAILS_ENV"] = "test"
|
||||
require 'pathname'
|
||||
|
||||
this_dir = Pathname.new File.dirname(__FILE__)
|
||||
$LOAD_PATH << this_dir.join("../lib")
|
||||
|
||||
|
@ -57,22 +56,24 @@ end
|
|||
# load test helpers
|
||||
require "rails"
|
||||
class MyApplication < Rails::Application ; end
|
||||
adapter = "sqlite3"
|
||||
adapter = ENV["ARE_DB"] || "sqlite3"
|
||||
|
||||
ActiveRecord::Base.logger = Logger.new("log/test.log")
|
||||
ActiveRecord::Base.logger.level = Logger::DEBUG
|
||||
ActiveRecord::Base.configurations["test"] = YAML.load(this_dir.join("database.yml").open)[adapter]
|
||||
ActiveRecord::Base.establish_connection "test"
|
||||
|
||||
ActiveSupport::Notifications.subscribe(/active_record.sql/) do |event, _, _, _, hsh|
|
||||
ActiveRecord::Base.logger.info hsh[:sql]
|
||||
end
|
||||
|
||||
require "factory_girl"
|
||||
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each{ |file| require file }
|
||||
|
||||
# Load base/generic schema
|
||||
require this_dir.join("schema/version")
|
||||
require this_dir.join("schema/generic_schema")
|
||||
|
||||
# Load adapter specific schema if one exists
|
||||
adapter_schema = this_dir.join("schema/#{adapter}_schema")
|
||||
adapter_schema = this_dir.join("schema/#{adapter}_schema.rb")
|
||||
require adapter_schema if File.exists?(adapter_schema)
|
||||
|
||||
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue