Files
wehub-resource-sync d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:55 +08:00

2.4 KiB

paths
paths
**/*.rb
**/*.rake
**/Gemfile
**/test/**/*.rb
**/spec/**/*.rb
**/config/routes.rb

Ruby テスト

このファイルは common/testing.md を Ruby および Rails 固有のコンテンツで拡張します。

フレームワーク

  • Rails アプリがデフォルトの Rails テストスタックに従っている場合は Minitest を使用する。
  • プロジェクトで既に確立されている場合、またはチームがそれに関する明確な本番規約を持っている場合は RSpec を使用する。
  • マイグレーションの理由なしに、同じ機能領域内で Minitest と RSpec を混在させない。

テストピラミッド

  • 高速なドメインロジックはモデル、サービス、クエリ、ポリシー、ジョブのテストに配置する。
  • HTTP コントラクト、認証動作、リダイレクト、ステータスコード、レスポンスの形状にはリクエスト/コントローラテストを使用する。
  • ブラウザ依存の重要なフローにのみ Capybara を使用したシステムテストを使用する。焦点を絞り、安定させる。
  • バックグラウンドジョブは動作のユニットテストとキュー/エンキューコントラクトの統合テストでカバーする。

フィクスチャとファクトリ

  • Rails フィクスチャがプロジェクトのデフォルトで、データグラフが小さい場合はそれを使用する。
  • シナリオが明示的なオブジェクト構築や複雑なトレイトを必要とする場合は factory_bot を使用する。
  • テストデータはアサートされる動作の近くに配置する。セットアップコストを隠すグローバルフィクスチャを避ける。

コマンド

プロジェクトローカルのコマンドを優先する:

bin/rails test
bin/rails test test/models/user_test.rb
bundle exec rspec
bundle exec rspec spec/models/user_spec.rb

カバレッジ

  • カバレッジが強制される場合は SimpleCov を使用する。しきい値は CI に設定し、低価値なテストでブランチカバレッジを水増ししない。
  • バグ修正では、本番コードを変更する前にリグレッションテストを追加する。

参考

リポジトリ全体の RED -> GREEN -> REFACTOR ループについてはスキル: tdd-workflow を参照。