Use with_model for test database setup - #110
Closed
nertzy wants to merge 1 commit into
Closed
Conversation
with_model 2.4 adds Test::Unit lifecycle integration, allowing the test suite to declare its tables instead of rebuilding the connection and schema procedurally at individual call sites. Replace TestDatabase with fixed-name with_table declarations so model inference and fixture filenames remain unchanged. Reset fixture and column caches at their lifecycle boundaries, and preserve generated fixture cleanup.
Collaborator
Author
nertzy
added a commit
that referenced
this pull request
Sep 5, 2026
Use with_model and with_table to give each Test::Unit case the fixed tables and model constants it exercises. Remove the suite-wide database reconnect and migration helper while preserving explicit manual boundaries for autoloading, separate pools, and raw SQL behavior. #110
nertzy
added a commit
that referenced
this pull request
Sep 5, 2026
Use with_model and with_table to give each Test::Unit case the fixed tables and model constants it exercises. Remove the suite-wide database reconnect and migration helper while preserving explicit manual boundaries for autoloading, separate pools, and raw SQL behavior. #110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixture_builder's Test::Unit suite currently owns a procedural database
helper that reconnects to SQLite and builds five tables at individual
test call sites.
with_model2.4 now provides Test::Unit lifecycleintegration, so the schema can instead follow each test's setup and
teardown automatically.
This replaces
TestDatabasewith a shared declarativeTestSchemausing fixed-name
with_tabledeclarations. Keeping the existing tablenames preserves fixture filenames and fixture_builder's model
inference.
The lifecycle also resets Active Record's fixture cache before setup,
refreshes model column information after table creation, and retains
the generated-fixture cleanup performed after each test.