inertia-rails-testing
Test Inertia Rails controller actions with RSpec matchers that verify rendered components, props, flash messages, and deferred data. Always use matchers like `render_component` and `have_props` instead of direct property access, and remember to call `follow_redirect!` after POST/PATCH/DELETE before asserting flash or props.
inertia-rails-testing provides RSpec matchers to verify Inertia component renders, props, and flash messages in controller specs.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-02-13
inertia-rails-testing provides RSpec matchers to verify Inertia component renders, props, and flash messages in controller specs. Test Inertia Rails controller actions with RSpec matchers that verify rendered components, props, flash messages, and deferred data. Always use matchers like `render_component` and `have_props` instead of direct property access, and remember to call `follow_redirect!` after POST/PATCH/DELETE before asserting flash or props.
Use it when
- inertia-rails-testing provides matchers like `render_component`, `have_props`, and `have_flash` for request specs.
- inertia-rails-testing requires calling `follow_redirect!` after POST, PATCH, or DELETE requests before asserting props or flash.
Verify before relying
Read SKILL.md below before installing (2 files). Open directory: indexed for reading, not audited.
Install
inertia-rails/skills/inertia-rails-testing
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I test Inertia Rails components with RSpec matchers?
inertia-rails-testing uses RSpec matchers to verify Inertia responses. Use `render_component` to assert which component was rendered, `have_props` to check passed props, and `have_flash` for flash messages. Always prefer matchers over direct property access: `expect(response).to render_component('Users/Index').with_props(count: 42)` instead of manually inspecting response data.
What's the correct way to test RSpec matchers for Inertia responses?
inertia-rails-testing provides matchers like `render_component`, `have_props`, and `have_flash` for request specs. Chain them to verify component name, passed props, and flash messages in a single assertion. Example: `expect(response).to render_component('Dashboard').with_props(user: @user).and_have_flash('success', 'Saved')`. These matchers replace manual JSON inspection.
How do I handle POST/PATCH/DELETE redirects in Inertia testing?
inertia-rails-testing requires calling `follow_redirect!` after POST, PATCH, or DELETE requests before asserting props or flash. The mutation endpoints redirect to a GET page; without following, you'll inspect the redirect response, not the target page. Example: `post '/users', params: {...}; follow_redirect!; expect(response).to have_flash('success')`.
How can I test deferred props and partial reload behavior?
inertia-rails-testing supports testing deferred props by verifying they appear in the response with lazy-load metadata. Use matchers to inspect the props structure and confirm deferred keys are present. For partial reloads, pass the `X-Inertia-Partial-Data` header in your request spec to simulate client-side partial updates, then assert only the specified props are returned.
What are the key testing patterns for Inertia Rails controller actions?
inertia-rails-testing establishes patterns: use `render_component` to verify the rendered component name, chain `with_props` to assert prop values, call `follow_redirect!` after mutations, and use `have_flash` for flash assertions. Avoid accessing response JSON directly; matchers provide clearer, more maintainable specs that document intent and catch regressions.
Can I convert RSpec patterns to Minitest for Inertia testing?
inertia-rails-testing is primarily RSpec-focused, but Minitest users can write custom assertions or use gems that bridge RSpec matchers. The core patterns—verifying component names, props, and flash—remain the same; only the assertion syntax changes. Consider using `assert_equal` on parsed response JSON or adopting RSpec alongside Minitest for integration tests.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Inertia Rails Testing
Testing patterns for Inertia responses with RSpec and Minitest.
For each controller action, verify:
- Correct component → render_component('users/index')
- Expected props → have_props(users: satisfy { ... })
- No leaked data → have_no_prop(:secret)
- Flash messages → follow_redirect! then have_flash(notice: '...')
- Deferred props → have_deferred_props(:analytics)
Common mistake: Forgetting follow_redirect! after PRG — without it, you're
asserting against the 302 redirect
(truncated - see the full file via the links below)
File tree — 2 files
skills/inertia-rails-testing/SKILL.md
skills/inertia-rails-testing/references/minitest.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Write RSpec tests for Inertia Rails controller actions using matchers”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Master server-side Inertia patterns in Rails controllers. Learn when to use render inertia with explicit props, how to defer expensive queries, share data across pages, and handle validation errors correctly. Covers prop types, flash messages, and the critical inertia_location rule for external redirects.
Inertia Coder guides you through building modern single-page applications that combine Inertia.js with Rails and your choice of React, Vue, or Svelte. It covers controller setup, page component patterns, form handling with the useForm hook, shared data management, and client-side routing—all without the complexity of separate APIs.
Rspec Coder streamlines Ruby testing by automatically generating RSpec test files and cases tailored to your codebase. Skip manual test scaffolding and focus on test logic while the skill handles boilerplate creation and structure.
Master the server-driven mental model behind Inertia Rails: the server owns routing, data, and auth while React renders UI only. This skill routes you to the right pattern for pages, forms, navigation, and data refresh through a decision matrix covering data sources, state ownership, and common anti-patterns to avoid.
Inertia Rails Pages provides patterns for constructing pages that maintain layout state across navigation, derive UI from URL parameters server-side, and use client-side router methods to update props without full reloads. It covers persistent layouts, prefetching, partial data refresh, and deferred component rendering across React, Vue, and Svelte.
This skill enables you to automatically generate Capybara acceptance tests for web applications, streamlining your test automation workflow. Built by LambdaTest (now TestMu AI), it simplifies the process of creating robust browser-based test scenarios without manual coding overhead.
More skills alba-inertia (MIT) · inertia-rails-typescript (MIT)