# Ruby Test

> Generate RSpec tests for Ruby/Rails classes

- Skill: `erp-core-dev/ruby-test` (Agent Skill)
- Install (CLI): `npx skillmds@latest add erp-core-dev/ruby-test`
- Raw SKILL.md: https://api.skillmd.com/api/skills/erp-core-dev/ruby-test/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ERP-CORE-DEV (https://skillmd.com/u/erp-core-dev)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/erp-core-dev/ruby-test

---


# Generate RSpec Tests

Generate RSpec tests for the given Ruby/Rails class or file.

## What To Do

1. **Read the target file** to understand public methods, validations, associations, and dependencies
2. **Generate spec file** at the correct spec/ path
3. **Define FactoryBot factory** if one does not exist
4. **Write examples** using describe/context/it blocks with Arrange-Act-Assert
5. **Cover edge cases**: nil attributes, invalid records, boundary values, unauthorized access

## Test Types

### Model Spec (default)
- describe ModelName, type: :model
- Test validations, associations, scopes, custom methods

### Request Spec (--type=request)
- describe "GET /entities", type: :request
- Test HTTP status codes, response body, auth gates

### Feature Spec (--type=feature)
- feature "User manages entities", type: :feature
- Capybara DSL: visit, click_on, fill_in, expect(page).to have_content

### Job Spec (--type=job)
- Test enqueue with have_enqueued_job matcher
- Test perform_now behavior with mocked dependencies

## Arguments
- `<class-or-file>`: Target class name or file path
- `--type=<model|request|feature|job>`: Spec type (default: model)

