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/database_adapters/activerecord/database_cleaner.rb similarity index 85% rename from spec/support/database_cleaner.rb rename to spec/database_adapters/activerecord/database_cleaner.rb index 312b7b3..e9dc858 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/database_adapters/activerecord/database_cleaner.rb @@ -1,4 +1,4 @@ -require 'database_cleaner' +require 'database_cleaner/active_record' RSpec.configure do |config| config.before :suite do diff --git a/spec/database_adapters/mongoid/database_cleaner.rb b/spec/database_adapters/mongoid/database_cleaner.rb new file mode 100644 index 0000000..51e01da --- /dev/null +++ b/spec/database_adapters/mongoid/database_cleaner.rb @@ -0,0 +1,14 @@ +require 'database_cleaner/mongoid' + +RSpec.configure do |config| + config.before :suite do + DatabaseCleaner.strategy = :deletion + DatabaseCleaner.clean_with :deletion + end + + config.around :each do |example| + DatabaseCleaner.cleaning do + example.run + end + end +end