Add Minitest support with assertion-style test helpers #302
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
This PR adds comprehensive Minitest testing support alongside the existing RSpec matchers, providing the same testing capabilities for Minitest users who prefer classic assertion-style testing.
Motivation
Currently, inertia-rails only provides test helpers for RSpec. Many Rails developers use Minitest (Rails' default testing framework), and this PR brings first-class Minitest support to make testing Inertia responses easy and intuitive for those users.
Changes
New Features
5 assertion methods for testing Inertia responses:
assert_inertia_component- Assert component name matchesassert_inertia_exact_props- Assert props match exactlyassert_inertia_includes_props- Assert props include specified keys/valuesassert_inertia_exact_view_data- Assert view data matches exactlyassert_inertia_includes_view_data- Assert view data includes specified keys/valuesAutomatic render interception via setup/teardown hooks
Configuration system (
InertiaRails::Minitest.config)Warning system for missing Inertia renderers (suppressible)
Full documentation in README.md with usage examples
Files Added/Modified
lib/inertia_rails/minitest.rb- New Minitest test helpers implementation (160 lines)spec/inertia/minitest_helper_spec.rb- Comprehensive test suite (320 lines, 23 passing specs)README.md- Added Minitest documentation section with examplesUsage
Implementation Details
InertiaRenderWrapperpattern used by RSpec helpersTesting
Documentation
Related
This addresses the need for Minitest support mentioned in the community and provides feature parity with the RSpec testing experience.