diff --git a/spec/factories/bulkrax/object_factory_spec.rb b/spec/models/bulkrax/object_factory_spec.rb similarity index 65% rename from spec/factories/bulkrax/object_factory_spec.rb rename to spec/models/bulkrax/object_factory_spec.rb index 907df758..2fb37897 100644 --- a/spec/factories/bulkrax/object_factory_spec.rb +++ b/spec/models/bulkrax/object_factory_spec.rb @@ -4,6 +4,8 @@ require Rails.root.parent.parent.join('spec', 'models', 'concerns', 'bulkrax', 'dynamic_record_lookup_spec').to_s module Bulkrax + # NOTE: Unable to put this file in spec/factories/bulkrax (where it would mirror the path in app/) because + # (presumably) FactoryBot autoloads all files in spec/factories, which would always run this spec. RSpec.describe ObjectFactory do subject(:object_factory) { build(:object_factory) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 0d9ba085..14da8cc4 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -43,6 +43,15 @@ RSpec.configure do |config| config.include FactoryBot::Syntax::Methods + config.before(:suite) do + DatabaseCleaner.clean_with :truncation + DatabaseCleaner.strategy = :transaction + end + + config.before do + DatabaseCleaner.start + end + config.after do begin DatabaseCleaner.clean