From 30e2fcfb2a59e5cc2e4f6a3d1e4d72fe8e0f289d Mon Sep 17 00:00:00 2001 From: markokajzer Date: Sun, 1 Dec 2024 19:53:37 +0100 Subject: [PATCH] deps: use correct database_cleaner adapter per database --- Gemfile | 9 ++++++++- spec/support/database_cleaner.rb | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 0eefdf4..b550fbb 100644 --- a/Gemfile +++ b/Gemfile @@ -6,11 +6,19 @@ when 'mongoid' then gem 'mongoid', ENV['MONGOID_VERSION'] || '~> 7.3.0' gem 'mongoid-scroll' gem 'mongoid-shell' + + group :development, :test do + gem 'database_cleaner-mongoid', '~> 2.0.1' + end when 'activerecord' then gem 'activerecord', ENV['ACTIVERECORD_VERSION'] || '~> 6.0.0' gem 'otr-activerecord' gem 'pagy_cursor', '~> 0.6.1' gem 'pg' + + group :development, :test do + gem 'database_cleaner-active_record', '~> 2.2.0' + end when nil warn "Missing ENV['DATABASE_ADAPTER']." else @@ -23,7 +31,6 @@ group :development, :test do gem 'bundler' gem 'byebug' gem 'capybara', '~> 3.36.0' - gem 'database_cleaner', '~> 2.1.0' gem 'fabrication' gem 'faker' gem 'faraday', '0.17.5' diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 312b7b3..cfbba63 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,4 +1,11 @@ -require 'database_cleaner' +case ENV.fetch('DATABASE_ADAPTER', nil) +when 'activerecord' + require 'database_cleaner/active_record' +when 'mongoid' + require 'database_cleaner/mongoid' +else + raise "Unknown database adapter #{ENV.fetch('DATABASE_ADAPTER', nil)}" +end RSpec.configure do |config| config.before :suite do