From e67b2936e58370bec4c559ef3f78af85eb291579 Mon Sep 17 00:00:00 2001 From: Ahmad Musaffa Date: Thu, 21 Mar 2019 00:58:05 +0600 Subject: [PATCH] Change Database Cleaner strategy I've an API project with 1700+ tests and it's growing. It used to take 15 to 20 minutes to run the complete suite. So I wanted to avoid running the suite at all cost. After a single change as suggested in this PR, the time dropped to 40 seconds. There's still a `truncation` strategy in the before suite hook. But when the tests start to run, transaction strategy is good enough. --- lib/dry/web/roda/templates/spec/db_spec_helper.rb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dry/web/roda/templates/spec/db_spec_helper.rb.tt b/lib/dry/web/roda/templates/spec/db_spec_helper.rb.tt index dfcee92..22db27f 100644 --- a/lib/dry/web/roda/templates/spec/db_spec_helper.rb.tt +++ b/lib/dry/web/roda/templates/spec/db_spec_helper.rb.tt @@ -6,7 +6,7 @@ Dir[SPEC_ROOT.join("support/db/*.rb").to_s].each(&method(:require)) Dir[SPEC_ROOT.join("shared/db/*.rb").to_s].each(&method(:require)) require "database_cleaner" -DatabaseCleaner[:sequel, connection: Test::DatabaseHelpers.db].strategy = :truncation +DatabaseCleaner[:sequel, connection: Test::DatabaseHelpers.db].strategy = :transaction RSpec.configure do |config| config.include Test::DatabaseHelpers