Skip to content

Commit

Permalink
Switch to Rspec native transactional fixtures to replace database cle…
Browse files Browse the repository at this point in the history
…aner

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.
  • Loading branch information
MrSerth committed Sep 25, 2024
1 parent e007101 commit 20d5e2d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 60 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ end

group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'factory_bot_rails'
gem 'pundit-matchers'
gem 'rails-controller-testing'
Expand Down
7 changes: 0 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ GEM
csv (3.3.0)
dachsfisch (1.0.0)
nokogiri (>= 1.14.1, < 2.0.0)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.2.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.4)
debug_inspector (1.2.0)
deep_merge (1.2.2)
Expand Down Expand Up @@ -608,7 +602,6 @@ DEPENDENCIES
capybara
coffee-rails
config
database_cleaner
devise (~> 4.9)
devise-bootstrap-views
factory_bot_rails
Expand Down
6 changes: 2 additions & 4 deletions spec/db/seeds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
Rake::Task['db:migrate'].invoke

# We want to execute the seeds for the dev environment against the test database
# rubocop:disable Rails/Inquiry
allow(Rails).to receive(:env) { 'development'.inquiry }
# rubocop:enable Rails/Inquiry
allow(Rails).to receive(:env) { 'development'.inquiry } # rubocop:disable Rails/Inquiry
allow(ActiveRecord::Base).to receive(:establish_connection).and_call_original
allow(ActiveRecord::Base).to receive(:establish_connection).with(:development) {
ActiveRecord::Base.establish_connection(:test)
}
end

describe 'execute db:seed', cleaning_strategy: :truncation do
describe 'execute db:seed' do
it 'collects the test results' do
expect { seed }.not_to raise_error
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
config.use_transactional_fixtures = true

# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false
Expand Down
47 changes: 0 additions & 47 deletions spec/support/database_cleaner.rb

This file was deleted.

0 comments on commit 20d5e2d

Please sign in to comment.