secondbase
secondbase copied to clipboard
Document DatabaseCleaner Examples
I think we can document some simple examples using SecondBase.on_base { ... } for test setup/teardown when using database cleaner. https://github.com/DatabaseCleaner/database_cleaner/tree/master/lib/database_cleaner/active_record
cc @sarsena
@metaskills that would be awesome I am using DatabaseCleaner, and https://github.com/grosser/parallel_tests
Any examples on how to do this?
Here is an example I have in a Rails v5.1 app.
require 'database_cleaner'
DatabaseCleaner.clean_with :truncation, except: [ActiveRecord::InternalMetadata.table_name]
DatabaseCleaner.clean
require 'factory_girl'
include FactoryGirl::Syntax::Methods
include NamedSeeds::DSL
begin
FactoryGirl.find_definitions
rescue
false
end
This is at the top of db/seeds.rb file