Module: Oaken::TestSetup::BeforeSetup

Defined in:
lib/oaken/test_setup.rb

Instance Method Summary collapse

Instance Method Details

#before_setupObject

We must inject late enough to call ‘should_parallelize?`, but before fixtures’ ‘before_setup`.

So we prepend into ‘before_setup` and later `super` to have fixtures wrap tests in transactions.



14
15
16
17
18
19
20
21
22
# File 'lib/oaken/test_setup.rb', line 14

def before_setup
  unless Minitest.parallel_executor.send(:should_parallelize?)
    ActiveRecord::Tasks::DatabaseTasks.truncate_all # Mimic fixtures by truncating before inserting.
    Oaken.load_seed
  end

  Oaken::TestSetup::BeforeSetup.remove_method :before_setup # Only run once, so remove before passing to fixtures in `super`.
  super
end