Skip to content

Commit

Permalink
Fix test db cleaning, stop running ObjectFactory spec when it isn't s…
Browse files Browse the repository at this point in the history
…upposed to be (#409)

* move object factory spec so it does not get run when it isn't supposed to be

* actually clean the test database after specs run
  • Loading branch information
bkiahstroud authored Feb 8, 2022
1 parent 552e532 commit 79e8825
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down
9 changes: 9 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79e8825

Please sign in to comment.