-
Notifications
You must be signed in to change notification settings - Fork 4
Configuration and Adapters
Use configuration to set fixture locations, cache locations, adapter behavior, callback hooks, and registered coders.
FixtureKit.configure do |config|
config.fixture_path = Rails.root.join("spec/fixture_kit").to_s
config.cache_path = Rails.root.join("tmp/cache/fixture_kit").to_s
config.adapter(FixtureKit::RSpecAdapter)
endAdapters isolate fixture generation inside framework-specific execution flow.
-
FixtureKit::RSpecAdapterexecutes generation in an internal RSpec example. -
FixtureKit::MinitestAdapterexecutes generation in an internalActiveSupport::TestCasetest.
Custom adapters should subclass FixtureKit::Adapter.
A Coder decides what gets cached during fixture generation and how to replay it on mount. By default, FixtureKit::ActiveRecordCoder is registered and captures all ActiveRecord writes inside FixtureKit.define { ... }.
Register additional coders to capture state outside ActiveRecord — Redis, Rails.cache, ActiveStorage blobs, etc.:
FixtureKit.configure do |config|
config.register(MyApp::RailsCacheCoder)
endEach registered coder owns its own slice of the cache file and runs alongside the others on every save/mount. See Coders for the full contract, examples, and chain semantics.
When ActiveRecord.verify_foreign_keys_for_fixtures is true (default since Rails 8.0 load_defaults), FixtureKit validates foreign keys after every mount. A violation raises FixtureKit::Error with a hint that the cache may be stale relative to your current schema. See Troubleshooting if you hit one.
For exact method signatures, defaults, callback contracts, and errors, use the canonical in-repo reference: