collab/config/initializers/in_memory_testing.rb

15 lines
496 B
Ruby
Raw Permalink Normal View History

2010-04-19 20:48:38 +00:00
def in_memory_database?
if %w{test cucumber}.member? ENV['RAILS_ENV']
ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter and
Rails::Configuration.new.database_configuration[ENV['RAILS_ENV']]['database'] == ':memory:'
else
false
end
end
if in_memory_database?
puts "creating sqlite in memory database"
load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
# ActiveRecord::Migrator.up('db/migrate') # use migrations
end