add support for in-memory testing

This commit is contained in:
John Bintz 2010-04-19 16:48:38 -04:00
parent 722bd7abe4
commit 3751f9b7e1
2 changed files with 14 additions and 4 deletions

View File

@ -0,0 +1,14 @@
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

View File

@ -76,8 +76,4 @@ ActiveRecord::Schema.define(:version => 20100316041234) do
t.datetime "updated_at" t.datetime "updated_at"
end end
add_foreign_key "projects", "users", :name => "projects_owner_id_fk", :column => "owner_id"
add_foreign_key "tasks", "users", :name => "tasks_owner_id_fk", :column => "owner_id"
end end