Reputation: 3119
It is easy to setup Datamapper with a Sqlite3 in memory database with: DataMapper.setup :default, 'sqlite3::memory:'.
However, when testing, I'd like to destroy the whole in memory database after each test, instead of invoking automigrate! as a shortcut on dropping everything. Is it possible? Or is it enough to set the default repository to nil, and let the garbage collector dispose of it?
Upvotes: 1
Views: 791
Reputation: 19485
My method of doing this is (in rspec):
Spec::Runner.configure do |config|
config.before(:all) do
DataMapper.auto_migrate!
end
config.before(:each) do
DataMapper::Repository.context << repository(:default)
end
config.after(:each) do
DataMapper::Repository.context.pop
end
end
Upvotes: 1