Rails in-memory sql db
database.yml:
test:
adapter: sqlite3
database: ":memory:"
at the end of spec/spec_helper.rb:
def in_memory_database?
Rails.env.test? and Rails.configuration.database_configuration['test']['database'] == ':memory:'
end
if in_memory_database?
puts "creating sqlite in memory database"
silence_stream(STDOUT) do
load "#{Rails.root}/db/schema.rb"
end
end
Written by pechorin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#