Merged
Conversation
Fixtures can now extend other fixtures via `extends:`, enabling
parent-child relationships that share setup data without duplication.
Key changes:
**Inheritance via `extends:`**
- Named fixtures: `FixtureKit.define(extends: "parent") { ... }`
- Inline fixtures: `fixture(extends: "parent") { ... }`
- Multi-level chains: grandchild -> child -> base
- `parent` helper available in definition blocks to access
parent's exposed records
**Cache includes parent records**
- Child cache files include all parent model records so replay
is self-contained
- Parent fixtures are generated before children automatically
**Circular dependency detection**
- Registry tracks a `@resolving` stack during fixture construction
- Re-entering a name already on the stack raises
`CircularFixtureInheritance` at registration time (fail fast)
**Internal refactors**
- `Fixture#cache` renamed to `Fixture#generate` (verb for triggering
generation), `@cache` is now the Cache object reader
- `Registry#add(name_or_definition, scope)` — name-first signature
- `Runner#register` is a simple passthrough to registry
- RSpec/Minitest entrypoints create `Definition` objects themselves
- Cache uses `MemoryData = Data.define(:records, :exposed)` with
model classes as keys instead of string names
- `Repository#load_record` uses `{ ModelClass => id }` format
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Adds fixture inheritance via
extends:, enabling parent-child relationships that share setup data without duplication. Child fixtures can access parent exposed records through aparenthelper and their cache files are self-contained (include all parent model records for replay).Inheritance API
Named fixtures (
spec/fixture_kit/child.rb):Inline fixtures (RSpec/Minitest):
Multi-level chains work automatically — grandchild extends child extends base. Parent fixtures are generated before children. Only the child's explicitly exposed records are accessible; parent records are not auto-exposed.
Circular dependency detection
The Registry tracks a
@resolvingstack during fixture construction. If a name is encountered that's already on the stack,CircularFixtureInheritanceis raised immediately at registration time (fail fast, no deferred errors).Internal refactors
Fixture#cache→Fixture#generate(the verb for triggering cache generation);Fixture#cacheis now theattr_readerfor the Cache objectRegistry#add(name_or_definition, scope)— name-first argument orderRunner#registersimplified to a passthrough to RegistryDefinitionobjects themselves before callingregisterMemoryData = Data.define(:records, :exposed)with model classes as hash keys instead of string namesRepository#load_recorduses{ ModelClass => id }format with.keys.first/.values.firstTest plan
bundle exec rspec)FIXTURE_KIT_INTEGRATION_FRAMEWORK=rspec)FIXTURE_KIT_INTEGRATION_FRAMEWORK=minitest)extends:andparenthelperCircularFixtureInheritanceraised at registration time🤖 Ngan's AI agent