Skip to content

Commit 951ac44

Browse files
committed
Switch to Rspec native transactional fixtures to replace database cleaner
With the previous change to system specs and the new framework defaults, we can drop the database cleaner entirely. All tests will only be executed as part of a transaction, and nothing is stored in the database.
1 parent ade9a17 commit 951ac44

5 files changed

Lines changed: 3 additions & 60 deletions

File tree

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ end
8585

8686
group :test do
8787
gem 'capybara'
88-
gem 'database_cleaner'
8988
gem 'factory_bot_rails'
9089
gem 'pundit-matchers'
9190
gem 'rails-controller-testing'

Gemfile.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@ GEM
136136
csv (3.3.0)
137137
dachsfisch (1.0.0)
138138
nokogiri (>= 1.14.1, < 2.0.0)
139-
database_cleaner (2.0.2)
140-
database_cleaner-active_record (>= 2, < 3)
141-
database_cleaner-active_record (2.2.0)
142-
activerecord (>= 5.a)
143-
database_cleaner-core (~> 2.0.0)
144-
database_cleaner-core (2.0.1)
145139
date (3.3.4)
146140
debug_inspector (1.2.0)
147141
deep_merge (1.2.2)
@@ -610,7 +604,6 @@ DEPENDENCIES
610604
capybara
611605
coffee-rails
612606
config
613-
database_cleaner
614607
devise (~> 4.9)
615608
devise-bootstrap-views
616609
factory_bot_rails

spec/db/seeds_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@
1414
Rake::Task['db:migrate'].invoke
1515

1616
# We want to execute the seeds for the dev environment against the test database
17-
# rubocop:disable Rails/Inquiry
18-
allow(Rails).to receive(:env) { 'development'.inquiry }
19-
# rubocop:enable Rails/Inquiry
17+
allow(Rails).to receive(:env) { 'development'.inquiry } # rubocop:disable Rails/Inquiry
2018
allow(ActiveRecord::Base).to receive(:establish_connection).and_call_original
2119
allow(ActiveRecord::Base).to receive(:establish_connection).with(:development) {
2220
ActiveRecord::Base.establish_connection(:test)
2321
}
2422
end
2523

26-
describe 'execute db:seed', cleaning_strategy: :truncation do
24+
describe 'execute db:seed' do
2725
it 'collects the test results' do
2826
expect { seed }.not_to raise_error
2927
end

spec/rails_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# If you're not using ActiveRecord, or you'd prefer not to run each of your
4343
# examples within a transaction, remove the following line or assign false
4444
# instead of true.
45-
config.use_transactional_fixtures = false
45+
config.use_transactional_fixtures = true
4646

4747
# You can uncomment this line to turn off ActiveRecord support entirely.
4848
# config.use_active_record = false

spec/support/database_cleaner.rb

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)