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:

  1. Ruby linting (Standard)
  2. ERB linting
  3. YAML linting
  4. Security audit (bundler-audit)
  5. JavaScript security scan
  6. Brakeman security scan
  7. Database setup
  8. Test suite

Usage: bundle exec rake test:ci

rake test:quick - Fast Linting Only

Runs only the fastest checks (linting):

  1. Ruby linting (Standard)
  2. 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):

  1. Ruby linting (Standard)
  2. ERB linting
  3. YAML linting
  4. Database setup
  5. Test suite

Usage: bundle exec rake test:precommit Best for: Before committing code

rake test:lint - Linting Only

Runs all linting checks:

  1. Ruby linting (Standard)
  2. ERB linting
  3. YAML linting

Usage: bundle exec rake test:lint

rake test:security - Security Only

Runs all security checks:

  1. Security audit (bundler-audit)
  2. JavaScript security scan
  3. 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

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:

  1. Better Error Handling: Security checks show warnings instead of failing CI
  2. Network Resilience: JavaScript security scan handles network issues gracefully
  3. Clear Output: Emoji indicators and clear success/failure messages
  4. Flexible Options: Different task levels for different needs
  5. 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 tasks
  • LIVE_MODE=true - Set for live test mode (makes real API calls)

Troubleshooting

Common Issues

  1. Security Audit Failures: These are often due to outdated gems. Update your Gemfile and run bundle update.

  2. JavaScript Security Scan Failures: Often due to network connectivity. The task handles this gracefully.

  3. Brakeman Warnings: Usually about gem versions. Update to latest versions when possible.

  4. Database Setup Failures: Ensure PostgreSQL is running and accessible.

Getting Help

  • Run bundle exec rake -T test to 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

This site uses Just the Docs, a documentation theme for Jekyll.