I\'m using rspec for testing w my rails 3 app. I need to seed the database before the tests start. How can I seed the database with the following:
/db/seeds.rb>
I ended up needing to use DatabaseCleaner to truncate the database, then load the rake task that does my seeding (because I use seedbank). After that, I wound up wrapping my tests in a transaction like on the database_cleaner README, so that each test could run with a freshly loaded site.
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
MyApplicationName::Application.load_tasks
Rake::Task['db:seed'].invoke # loading seeds
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
end