Test Fixer Agent
Systematically diagnoses and fixes failing RSpec tests. When your CI is red and you don't know why, this agent finds the root cause and applies the right fix.
The Red CI Syndrome
Tests fail. Sometimes the reason is obvious. Often it's not:
- "The test was passing yesterday" — something changed, but what?
- "It works when I run it locally" — environment differences strike again
- "I didn't touch that code" — indirect dependencies break things
- "The error message makes no sense" — cryptic stack traces
The result? Hours lost debugging. Features blocked waiting for green CI. Technical debt piling up as teams skip "unrelated" test fixes.
How the Agent Works
Test Suite Analysis
Maps the current state of your test suite.
- → Runs full test suite to identify all failures
- → Isolates each failing spec to rule out order dependencies
- → Categorizes failures: assertion errors, exceptions, timeouts
Failure Diagnosis
Determines whether the test or the code is wrong.
- → Checks if code changed intentionally (test needs update)
- → Checks if it's a bug (code needs fix)
- → Analyzes stack traces to find the actual problem location
Test Data Verification
Ensures factories and fixtures produce valid test data.
- → Checks factory definitions match current model requirements
-
→
Verifies
letvslet!usage for proper setup timing - → Validates database constraints and foreign keys
Fix Application
Applies the appropriate fix based on diagnosis.
- → Updates test expectations when code changed intentionally
- → Fixes bugs in application code when test is correct
- → Corrects factory/fixture data when setup is wrong
Full Suite Validation
Ensures the fix doesn't break anything else.
- → Runs linters to check syntax and style
- → Runs full test suite to confirm no regressions
- → PR is only submitted when all tests pass.
Optional: Coverage Expansion
Beyond fixing failing tests, we can identify gaps between production data and test data.
Production Error Analysis
Analyzes error logs to find untested edge cases that break in production.
Boundary Conditions
Generates property-based tests for edge cases your team didn't think of.
Negative Tests
Adds tests for nil values, empty strings, and invalid states.
Common Issues We Fix
Assertion Failures
Expected value changed due to intentional refactoring.
Fix: Update expectation to match new behavior
NoMethodError
Method was renamed or moved during refactoring.
Fix: Update test to use new method name
NilError
Test setup doesn't create required associations.
Fix: Add missing let! or factory associations
Foreign Key Violations
Records created in wrong order or missing dependencies.
Fix: Reorder creation or add dependent records
Safety Guarantees
Diagnosis Before Fix
Understands the root cause before applying any changes.
Full Suite Regression Check
Every fix is validated against the entire test suite.
No Stubbing Hacks
Uses real data, not mock workarounds that hide bugs.
Clear Explanations
Every PR explains what was wrong and why the fix works.
Linter Compliance
All changes pass RuboCop and any other configured linters.
Minimal Changes
Fixes only what's broken. No scope creep or unnecessary refactoring.
What This Is NOT
- ✗ Not skipping tests. We fix them, not mark them pending.
- ✗ Not stubbing everything. Real data catches real bugs.
- ✗ Not blind pattern matching. Understands why tests fail before fixing.
- ✗ Not changing test behavior. Fixed tests still catch the bugs they were designed for.
Typical Results
Ready to Get Back to Green?
Start with a $1,500 audit. Get a full test suite health report with prioritized fixes for failing tests.