Skip to content

Commit

Permalink
Add database_cleaner-active_record
Browse files Browse the repository at this point in the history
  • Loading branch information
zakariaf committed Dec 26, 2021
1 parent 436743f commit 653e37e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ group :test do
gem "webdrivers"
gem 'factory_bot_rails'
gem 'faker'
gem 'database_cleaner-active_record'
end
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ GEM
childprocess (4.1.0)
concurrent-ruby (1.1.9)
crass (1.0.6)
database_cleaner-active_record (2.0.1)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
debug (1.4.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
Expand Down Expand Up @@ -218,6 +222,7 @@ PLATFORMS
DEPENDENCIES
bootsnap
capybara
database_cleaner-active_record
debug
factory_bot_rails
faker
Expand Down
16 changes: 16 additions & 0 deletions spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'database_cleaner/active_record'

RSpec.configure do |config|
# start by truncating all the tables but then use the faster transaction strategy the rest of the time.
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :transaction
end

# start the transaction strategy as examples are run
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
end

0 comments on commit 653e37e

Please sign in to comment.