Rake Tasks Documentation
This document describes the available rake tasks for testing, linting, and CI checks.
Test Tasks
Basic Test Tasks
rake test:stubbed- Run tests in stubbed mode (default, external services stubbed)rake test:live- Run tests in live mode (makes real API calls, requires confirmation)rake test:live_ci- Run tests in live mode without confirmation (for CI)
CI and Quality Assurance Tasks
rake test:ci - Full CI Pipeline
Runs all the same checks as the CI pipeline:
- Ruby linting (Standard)
- ERB linting
- YAML linting
- Security audit (bundler-audit)
- JavaScript security scan
- Brakeman security scan
- Database setup
- Test suite
Usage: bundle exec rake test:ci
rake test:quick - Fast Linting Only
Runs only the fastest checks (linting):
- Ruby linting (Standard)
- ERB linting
Usage: bundle exec rake test:quick
Best for: Quick code style checks before committing
rake test:precommit - Pre-commit Checks
Runs linting and tests (recommended before committing):
- Ruby linting (Standard)
- ERB linting
- YAML linting
- Database setup
- Test suite
Usage: bundle exec rake test:precommit
Best for: Before committing code
rake test:lint - Linting Only
Runs all linting checks:
- Ruby linting (Standard)
- ERB linting
- YAML linting
Usage: bundle exec rake test:lint
rake test:security - Security Only
Runs all security checks:
- Security audit (bundler-audit)
- JavaScript security scan
- Brakeman security scan
Usage: bundle exec rake test:security
Task Comparison
| Task | Ruby Lint | ERB Lint | YAML Lint | Security | Tests | Speed |
|---|---|---|---|---|---|---|
test:quick |
PASS | PASS | - | - | - | Fastest |
test:lint |
PASS | PASS | PASS | - | - | Fast |
test:precommit |
PASS | PASS | PASS | - | PASS | Medium |
test:security |
- | - | - | PASS | - | Medium |
test:ci |
PASS | PASS | PASS | PASS | PASS | Slowest |
Recommended Workflow
For Daily Development
# Quick style check
bundle exec rake test:quick
# Before committing
bundle exec rake test:precommit
For CI/Deployment
# Full CI pipeline
bundle exec rake test:ci
For Security Review
# Security checks only
bundle exec rake test:security
CI Improvements
The rake tasks include several improvements over the basic CI:
- Better Error Handling: Security checks show warnings instead of failing CI
- Network Resilience: JavaScript security scan handles network issues gracefully
- Clear Output: Emoji indicators and clear success/failure messages
- Flexible Options: Different task levels for different needs
- Comprehensive Coverage: All CI checks plus additional YAML linting
Exit Codes
- 0: All checks passed
- 1: One or more critical checks failed
Security warnings do not cause failures - they are informational only.
Environment Variables
RAILS_ENV=test- Automatically set for test tasksLIVE_MODE=true- Set for live test mode (makes real API calls)
Troubleshooting
Common Issues
-
Security Audit Failures: These are often due to outdated gems. Update your Gemfile and run
bundle update. -
JavaScript Security Scan Failures: Often due to network connectivity. The task handles this gracefully.
-
Brakeman Warnings: Usually about gem versions. Update to latest versions when possible.
-
Database Setup Failures: Ensure PostgreSQL is running and accessible.
Getting Help
- Run
bundle exec rake -T testto see all available test tasks - Check the CI logs for detailed error messages
- Security warnings are informational - review them but they won’t block deployment