Skip to content

carapace-sh/carapace-bin / skills/rails

Use when working with the Rails CLI — commands, generators, database tasks, test subcommands, rake tasks, flags, and argument completion. Triggers on: "rails", "Ruby on Rails", "bin/rails", "rails new", "rails generate", "rails server", "rails console", "rails dbconsole", "rails runner", "rails test", "rails routes", "rails destroy", "rails db", "rails credentials", "rails middleware", "rails notes", "rails dev:cache", "rails restart", "rails secret", "rails stats", "rails about", "rails boot", "rails initializers", "rails plugin", "rails tmp", "rails version", "rails devcontainer", "rails encrypted", "rails zeitwerk", "rails yarn", "rails scaffold", "rails model", "rails migration", "rails controller", "rails resource", "rails job", "rails mailer", "rails channel", "railsrc", ".railsrc", "config/database.yml".

FileKindSize
SKILL.mdskill md8.5 KB
references/cli-commands.mdmarkdown9.6 KB
references/configuration.mdmarkdown14.5 KB
references/database.mdmarkdown7.0 KB
references/environment.mdmarkdown7.7 KB
references/generators.mdmarkdown12.4 KB
references/rails-new.mdmarkdown4.9 KB
references/rake-tasks.mdmarkdown3.8 KB
references/testing.mdmarkdown3.5 KB

references/testing.md

View on GitHub
# Test Commands

All `rails test:*` subcommands. Rails wraps Minitest with custom runner logic for default test paths, line-number filtering, and subcommand-based test directory selection.

> **Source of truth**: `railties/lib/rails/commands/test/test_command.rb` and `railties/lib/rails/test_unit/runner.rb`.

## `rails test` (`t`)

**Usage:** `bin/rails test [PATHS...] [options]`

Runs tests in default test directories (excluding `test/system`).

### Positional Arguments

Paths to test files or directories. Can be:

| Pattern | Example | Behavior |
|---------|---------|----------|
| File path | `test/models/user_test.rb` | Run that file |
| File:line | `test/models/user_test.rb:27` | Run test at that line |
| File:range | `test/models/user_test.rb:10-20` | Run tests in line range |
| Directory | `test/controllers` | Run all tests in that dir |
| Multiple | `test/controllers test/integration/login_test.rb` | Run all specified |

### Minitest Options

| Flag | Alias | Type | Description |
|------|-------|------|-------------|
| `--name` | `-n` | string/pattern | Filter by test name (regex) |
| `--verbose` | `-v` | bool | Verbose output |
| `--seed` | — | int | Random seed |
| `--no-plugins` | — | bool | Disable plugins |
| `--warnings` | `-w` | bool | Run with Ruby warnings enabled |
| `--environment` | `-e` | string | Run in specified environment |
| `--help` | `-h` | — | Show Minitest help |

## Test Subcommands

### `test:all`

Run all tests including system tests.

### `test:system`

Run system tests only (in `test/system/`).

### `test:functionals`

Run functional tests (`test/controllers/`, `test/mailers/`, `test/functional/`).

### `test:units`

Run unit tests (`test/models/`, `test/helpers/`, `test/unit/`).

### `test:generators`

Run generator tests (`test/lib/generators/`).

### `test:models`

Run model tests (`test/models/`).

### `test:helpers`

Run helper tests (`test/helpers/`).

### `test:channels`

Run channel tests (`test/channels/`).

### `test:controllers`

Run controller tests (`test/controllers/`).

### `test:mailers`

Run mailer tests (`test/mailers/`).

### `test:integration`

Run integration tests (`test/integration/`).

### `test:jobs`

Run job tests (`test/jobs/`).

### `test:mailboxes`

Run mailbox tests (`test/mailboxes/`).

### `test:db`

Reset test database and run `bin/rails test` (equivalent to `rails db:test:prepare && rails test`).

## Runner Architecture

- `Rails::TestUnit::Runner` manages test loading
- Default test file glob: `test/**/*_test.rb`
- System tests excluded from default `rails test` (use `rails test:system` or `rails test:all`)
- Line number filtering uses Minitest's `--name` option with a generated regex from the test file's AST
- `--environment` defaults to `test`

## Edge Cases

- **Line numbers** (`file:27`) match the test method definition line, not any arbitrary line. If the line doesn't match a test method, it runs the entire file.
- **`test:db`** is a convenience alias for `db:test:prepare && test`. Use it to avoid running migrations separately.
- **All subcommands** accept the same Minitest options as `rails test`.
- **No subcommand for system tests by default** — only `test:system` targets them.
- **`test:functionals` and `test:units`** are legacy terms kept for backwards compatibility; prefer the named subcommands (`test:controllers`, `test:models`, etc.).

## Related Skills

- For `rails test:db` which delegates to `db:test:prepare`, see [database.md](database.md).
- For the general CLI command structure, see [cli-commands.md](cli-commands.md).
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall