Class: RSpecTurbo::DbSetup
- Inherits:
-
Object
- Object
- RSpecTurbo::DbSetup
- Defined in:
- lib/rspec_turbo/db_setup.rb
Overview
Ensures N test databases exist, one per worker slot, by spawning a Rails db setup process per slot (each with its own TEST_ENV_NUMBER).
The result is cached by a fingerprint of db/schema.rb + db/seeds.rb plus the worker count, so repeat runs skip setup entirely. Set RSPEC_TURBO_FORCE_SETUP=1 to force recreation.
Constant Summary collapse
- FINGERPRINT_FILES =
["db/schema.rb", "db/seeds.rb"].freeze
- SETUP_COMMAND =
["bundle", "exec", "rails", "db:drop", "db:create", "db:schema:load", "db:seed"].freeze
Instance Method Summary collapse
- #cached? ⇒ Boolean
-
#initialize(num_workers, force: Config.force_setup?) ⇒ DbSetup
constructor
A new instance of DbSetup.
- #run! ⇒ Object
Constructor Details
#initialize(num_workers, force: Config.force_setup?) ⇒ DbSetup
Returns a new instance of DbSetup.
17 18 19 20 |
# File 'lib/rspec_turbo/db_setup.rb', line 17 def initialize(num_workers, force: Config.force_setup?) @n = num_workers @force = force end |
Instance Method Details
#cached? ⇒ Boolean
34 |
# File 'lib/rspec_turbo/db_setup.rb', line 34 def cached? = File.exist?(marker_path) |