Token导航 LogoToken导航TokenDH.com
待分类需要联网github未标认证来源可访问许可证需确认审计通过

inertia-rails-testinginertia Rails 测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

2,940

周安装

125

GitHub Stars

44

下载量

1,030
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:inertia-rails-testing(inertia Rails 测试)
来源仓库:https://github.com/inertia-rails/skills
仓库路径:skills/inertia-rails-testing
安装命令:
npx skills add https://github.com/inertia-rails/skills --skill inertia-rails-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/inertia-rails/skills --skill inertia-rails-testing

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合让 Agent 编写单元测试、端到端测试或根据日志定位问题。
  • 使用时需要确认项目测试框架、运行命令和夹具数据。inertia-rails-testing 属于待分类类 Skill,可作为该场景下的辅助能力补充。
  • 涉及浏览器或外部服务时,应区分本地模拟与生产环境。
  • 避免为了通过测试而改坏真实逻辑,需核对权限和执行边界。

SKILL.md

Inertia Rails Testing

Testing patterns for Inertia responses with RSpec and Minitest.

For each controller action, verify:

  • Correct componentrender_component('users/index')
  • Expected propshave_props(users: satisfy {...})
  • No leaked datahave_no_prop(:secret)
  • Flash messagesfollow_redirect! then have_flash(notice: '...')
  • Deferred propshave_deferred_props(:analytics)

Common mistake: Forgetting follow_redirect! after PRG — without it, you're asserting against the 302 redirect response, not the Inertia page that follows.

Setup

# spec/rails_helper.rb
require 'inertia_rails/rspec'

RSpec Matchers

MatcherPurpose
be_inertia_responseVerify response is Inertia format
render_component('path')Check rendered component name
have_props(key: value)Partial props match
have_exact_props(key: value)Exact props match
have_no_prop(:key)Assert prop absent
have_flash(key: value)Partial flash match
have_exact_flash(key: value)Exact flash match
have_no_flash(:key)Assert flash absent
have_deferred_props(:key)Check deferred props exist
have_view_data(key: value)Partial view_data match

RSpec Examples

ALWAYS use matchers (render_component, have_props, have_flash) instead of direct property access (inertia.component, inertia.props[:key]):

# BAD — direct property access:
# expect(inertia.component).to eq('users/index')
# expect(inertia.props[:users].length).to eq(3)

# GOOD — use matchers:
expect(inertia).to render_component('users/index')
expect(inertia).to have_props(users: satisfy { |u| u.length == 3 })
# Key pattern: follow_redirect! after POST/PATCH/DELETE before asserting
it 'redirects with flash on success' do
  post users_path, params: { user: valid_params }

  expect(response).to redirect_to(users_path)
  follow_redirect!
  expect(inertia).to have_flash(notice: 'User created!')
end

it 'returns validation errors on failure' do
  post users_path, params: { user: { name: '' } }

  follow_redirect!
  expect(inertia).to have_props(errors: hash_including('name' => anything))
end

Test Shared Props

Shared props from inertia_share are included in inertia.props. The inertia helper is available in type::request specs after requiring inertia_rails/rspec:

it 'includes shared auth data' do
  sign_in(user)
  get dashboard_path

  expect(inertia).to have_props(
    auth: hash_including(user: hash_including(id: user.id))
  )
end
it 'excludes auth data for unauthenticated users' do
  get dashboard_path

  expect(inertia).to have_props(auth: hash_including(user: nil))
end

Test Deferred Props

it 'defers expensive analytics data' do
  get dashboard_path

  expect(inertia).to have_deferred_props(:analytics, :statistics)
  expect(inertia).to have_deferred_props(:slow_data, group: :slow)
end

Partial Reload Helpers

it 'supports partial reload' do
  get users_path

  # Simulate partial reload — only fetch specific props
  inertia_reload_only(:users, :pagination)

  # Or exclude specific props
  inertia_reload_except(:expensive_stats)

  # Load deferred props
  inertia_load_deferred_props(:default)
  inertia_load_deferred_props # loads all groups
end

Test External Redirects (inertia_location)

it 'redirects to Stripe via inertia_location' do
  post checkout_path

  # inertia_location returns 409 with X-Inertia-Location header
  expect(response).to have_http_status(:conflict)
  expect(response.headers['X-Inertia-Location']).to match(/stripe\.com/)
end

NEVER Test These

  • Inertia framework behavior — don't test that <Form> sends CSRF tokens or that router.visit works. Test YOUR controller logic.
  • Exact prop structure — use have_props(users: satisfy {...}), not deep equality on full JSON. Brittle tests break when you add a column.
  • Flash without follow_redirect! — after POST/PATCH/DELETE with redirect, you MUST follow_redirect! before asserting flash or props. Without it you're asserting against the 302, not the page.
  • Deferred prop values on initial load — deferred props are nil in the initial response because they're fetched in a separate request after page render. Use have_deferred_props(:key) to verify they're registered, or inertia_load_deferred_props to resolve them in tests.
  • Mocked Inertia responses — use type::request specs that exercise the full stack. type::controller specs with assigns don't work because Inertia uses a custom render pipeline that only executes in the full request cycle.

Direct Access (use matchers above when possible)

inertia.component       # => 'users/index'
inertia.props           # => { users: [...] }
inertia.props[:users]   # direct prop access
inertia.flash           # => { notice: 'Created!' }
inertia.deferred_props  # => { default: [:analytics], slow: [:report] }

Related Skills

  • Controller patternsinertia-rails-controllers (prop types, flash, PRG)
  • Form flowsinertia-rails-forms (submission, validation)
  • Deferred/shared propsinertia-rails-pages (Deferred, usePage)

References

MANDATORY — READ ENTIRE FILE when writing Minitest tests (not RSpec): references/minitest.md (~40 lines) — Minitest assertions equivalent to the RSpec matchers above.

Do NOT load minitest.md for RSpec projects — the matchers above are all you need.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.72%
按下载量换算358

Claude

30.32%
按下载量换算312

Cursor

19.5%
按下载量换算201

Gemini CLI

10.11%
按下载量换算104

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills