home / skills / fortiumpartners / ai-mesh / rspec-test

rspec-test skill

/skills/rspec-test

This skill executes and generates RSpec tests for Ruby projects, including let bindings and before hooks, with mocking support.

npx playbooks add skill fortiumpartners/ai-mesh --skill rspec-test

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
534 B
---
name: RSpec Test Framework
description: Execute and generate RSpec tests for Ruby projects with let bindings, before hooks, and mocking support
version: 1.0.0
---

# RSpec Test Framework

## Purpose

Provide RSpec test execution and generation for Ruby projects.

## Usage

```bash
ruby generate-test.rb --source=lib/calculator.rb --output=spec/calculator_spec.rb --description="Division by zero"
ruby run-test.rb --file=spec/calculator_spec.rb
```

## Output Format

JSON with success, passed, failed, total, and failures array.

Overview

This skill executes and generates RSpec tests for Ruby projects, including support for let bindings, before hooks, and mocking. It automates test creation from source files and runs specs, returning structured JSON results for integration with CI and agent workflows. It is designed to speed up writing focused unit tests and to produce machine-readable test outcomes.

How this skill works

The skill analyzes Ruby source files to scaffold RSpec examples and helper blocks (let, before) that capture common setup. It can generate spec files from given source paths and descriptions, and it runs RSpec on specific spec files or suites. Test runs produce JSON with overall success, counts for passed/failed/total, and an array of failure details for easy parsing.

When to use it

  • Generating starter RSpec specs from source files to bootstrap test coverage
  • Running single spec files or full suites in CI or local development
  • Creating tests that require reusable let bindings and shared before setup
  • Validating behavior with mocks/stubs for external dependencies
  • Collecting structured test results for dashboards or automation

Best practices

  • Provide a clear description for each generated test so assertions map to expected behavior
  • Use let and before to keep examples focused and reduce duplication
  • Mock external services or heavy dependencies to keep unit tests fast and deterministic
  • Run generated tests locally and iterate on assertions before committing to CI
  • Consume the JSON result in tooling to fail builds or triage regressions automatically

Example use cases

  • Generate a spec for calculator division behavior and inspect edge cases like division by zero
  • Run a single spec file in a pre-commit hook and parse JSON to display concise failure summaries
  • Create specs that use before hooks to set up database records and let to define subject instances
  • Mock HTTP clients when generating tests for classes that call external APIs
  • Integrate test execution into an agent that automatically opens issues for failing specs

FAQ

What does the test runner output look like?

The runner returns JSON with success boolean, passed, failed, total counts, and a failures array with details for each failed example.

Can it generate tests that use mocks and stubs?

Yes. The generator can scaffold examples that set up mocks and stubs for dependencies so tests remain isolated and fast.