Skip to content

Comments

Evaluate fixture definitions in adapter execution context#28

Merged
ngan merged 2 commits intomainfrom
np-definition-context-mixin
Feb 24, 2026
Merged

Evaluate fixture definitions in adapter execution context#28
ngan merged 2 commits intomainfrom
np-definition-context-mixin

Conversation

@ngan
Copy link
Collaborator

@ngan ngan commented Feb 24, 2026

Summary

This updates fixture definition evaluation so fixture blocks run on the real framework execution context (RSpec example instance / Minitest test instance) while still routing expose(...) back to the current FixtureKit::Definition.

Changes

  • Pass execution context from adapters into definition evaluation:
    • lib/fixture_kit/adapters/rspec_adapter.rb
    • lib/fixture_kit/adapters/minitest_adapter.rb
    • lib/fixture_kit/cache.rb
  • Change FixtureKit::Definition#evaluate to require a context and execute the definition on that context.
  • Dynamically prepend a small mixin to the context singleton class to provide expose(...) delegation to the current definition.
  • Add regression coverage for helper methods inside fixture blocks (travel_to in RSpec integration).
  • Update unit tests for Definition#evaluate(context).

Why

Fixture blocks could not call instance helper methods from the framework test context (e.g. travel_to from included RSpec helpers), because definitions previously executed with self == FixtureKit::Definition.

Validation

  • bundle exec rspec --fail-fast spec/unit/definition_spec.rb spec/unit/rspec_adapter_spec.rb spec/unit/minitest_adapter_spec.rb spec/unit/fixture_cache_spec.rb spec/integration/dummy_app_spec.rb
  • FIXTURE_KIT_INTEGRATION_FRAMEWORK=minitest bundle exec rspec --fail-fast spec/integration/dummy_app_spec.rb

@ngan ngan merged commit 8830f2f into main Feb 24, 2026
8 checks passed
@ngan ngan deleted the np-definition-context-mixin branch February 24, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant