ruby 代码
- database.yml
- test:
- adapter: sqlite3
- database: ":memory:"
- environment.rb
- config.active_record.schema_format = :ruby
- def in_memory_database?
- ENV["RAILS_ENV"] == "test" and
- ActiveRecord::Base.connection.class==ActiveRecord::ConnectionAdapters::SQLiteAdapter and
- Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
- 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