{"id":16070132,"url":"https://github.com/danmayer/coverband_rails_example","last_synced_at":"2026-04-16T06:02:15.361Z","repository":{"id":223583724,"uuid":"760956283","full_name":"danmayer/coverband_rails_example","owner":"danmayer","description":"A Rails App to show how to use coverband","archived":false,"fork":false,"pushed_at":"2026-01-19T23:44:14.000Z","size":227,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-31T00:15:20.085Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danmayer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-21T01:00:47.000Z","updated_at":"2026-01-19T23:44:19.000Z","dependencies_parsed_at":"2024-11-18T14:52:33.302Z","dependency_job_id":"5b8d6ade-1034-459c-bc73-4cf7495b3260","html_url":"https://github.com/danmayer/coverband_rails_example","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"5eb3417ebbbe86e3c1be0368ad20de5b47a5633f"},"previous_names":["danmayer/coverband_rails_example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danmayer/coverband_rails_example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmayer%2Fcoverband_rails_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmayer%2Fcoverband_rails_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmayer%2Fcoverband_rails_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmayer%2Fcoverband_rails_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danmayer","download_url":"https://codeload.github.com/danmayer/coverband_rails_example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmayer%2Fcoverband_rails_example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31873606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T07:01:33.763Z","updated_at":"2026-04-16T06:02:15.355Z","avatar_url":"https://github.com/danmayer.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coverband Rails Demo\n\nA comprehensive demonstration application showcasing all of [Coverband's](https://github.com/danmayer/coverband) features, configuration options, and performance characteristics. This demo helps you understand how Coverband works and how to integrate it into your Rails applications.\n\nSee the live shared demo [https://coverband-rails-example.onrender.com/](https://coverband-rails-example.onrender.com/)\n\n## What is Coverband?\n\nCoverband is a Ruby code coverage tool for production environments. Unlike traditional test coverage tools, Coverband tracks which code is actually executed in production, helping you:\n\n- Identify dead code and unused features\n- Track view, translation, and route usage\n- Understand runtime code execution patterns\n- Make informed decisions about refactoring and deprecation\n\n## Features Demonstrated\n\nThis demo showcases all major Coverband features:\n\n# Deploy to Render\n\nThis application is configured to be easily deployed on [Render.com](https://render.com). on our subdomain [coverband-rails-example.onrender.com](https://coverband-rails-example.onrender.com/)\n\n1.  Fork this repository.\n2.  Create a new Web Service on Render.\n3.  Connect your GitHub account and select your forked repository.\n4.  Render will automatically detect the `render.yaml` blueprint (or you can select \"Docker\" as the runtime).\n5.  **Important:** Coverband requires Redis. Render does not offer a free Redis instance that persists.\n    *   Sign up for a free Redis instance at [Upstash](https://upstash.com/) or [Redis Cloud](https://redis.com/try-free/).\n    *   Get your Redis connection URL (e.g., `redis://default:password@fly-foo-bar.upstash.io:6379`).\n    *   In the Render dashboard for your service, add an Environment Variable named `REDIS_URL` with your connection string.\n✅ **Code Coverage Tracking** - Real-time line-by-line coverage analysis\n✅ **View Tracking** - Monitor which views and partials are rendered\n✅ **Translation Tracking** - Discover which I18n keys are used\n✅ **Router Tracking** - Track which routes are accessed\n✅ **Configuration Options** - Test different storage backends and settings\n✅ **Performance Benchmarks** - Measure Coverband's impact\n✅ **Memory Profiling** - Understand memory usage and overhead\n\n## Quick Start\n\n### Prerequisites\n\n- Ruby 3.4.7 (or 3.2+)\n- Rails 7.1+\n- Redis (for coverage storage)\n\n### Installation\n\n```bash\ngit clone git@github.com:danmayer/coverband_rails_example.git\ncd coverband_rails_example\nbundle install\n```\n\n### Setup Database\n\n```bash\nbundle exec rails db:create\nbundle exec rails db:migrate\nbundle exec rails db:seed  # Optional: create sample data\n```\n\n### Start Redis\n\n```bash\n# macOS with Homebrew\nbrew services start redis\n\n# Linux\nsudo systemctl start redis\n\n# Or run directly\nredis-server\n```\n\n### Start the Application\n\n```bash\nbundle exec rails server\n```\n\n### Explore the Demo\n\nOpen your browser and visit:\n\n- **Demo Home**: http://localhost:3000\n- **Coverage Report**: http://localhost:3000/coverage\n- **Configuration**: http://localhost:3000/demo/configuration\n- **Benchmarks**: http://localhost:3000/demo/benchmarks\n- **Memory Profiling**: http://localhost:3000/demo/profiling\n\n## Understanding Coverband Features\n\n### Code Coverage\n\nNavigate through the app (posts, books, demo pages) to generate coverage data. Then view the coverage report at `/coverage` to see:\n\n- Which lines of code were executed\n- Coverage percentages for each file\n- Runtime vs test coverage comparison\n\n### View Tracking\n\nEnabled by default in this demo. Coverband tracks which views and partials are rendered. Check the coverage report to see view usage statistics.\n\n**Configuration**: `config.track_views = true`\n\n### Translation Tracking\n\nThis demo includes English and Spanish translations. Coverband tracks which I18n keys are actually used in your application.\n\n**Configuration**: `config.track_translations = true`\n\n**Try it**:\n- Browse the demo pages to trigger translation key usage\n- Check the coverage report for translation statistics\n\n### Router Tracking\n\nMonitors which routes are accessed in your application, helping you identify unused endpoints.\n\n**Configuration**: `config.track_routes = true`\n\n## Configuration Options\n\nCoverband is highly configurable. This demo lets you test different configurations using environment variables.\n\n### Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `COVERBAND_TRACK_VIEWS` | `true` | Enable/disable view tracking |\n| `COVERBAND_TRACK_TRANSLATIONS` | `true` | Enable/disable translation tracking |\n| `COVERBAND_TRACK_ROUTES` | `true` | Enable/disable route tracking |\n| `COVERBAND_VERBOSE` | `false` | Enable verbose logging |\n| `COVERBAND_HASH_STORE` | `false` | Use HashRedisStore for better performance |\n| `COVERBAND_PAGER` | `false` | Enable paged reporting for large apps |\n| `COVERBAND_DISABLE_AUTO_START` | `false` | Disable coverage collection (for benchmarking) |\n\n### Example Configurations\n\n**Minimal (Fastest Performance)**\n```bash\nCOVERBAND_TRACK_VIEWS=false \\\nCOVERBAND_TRACK_TRANSLATIONS=false \\\nCOVERBAND_TRACK_ROUTES=false \\\nbundle exec rails s\n```\n\n**Full Tracking (Recommended for Development)**\n```bash\nCOVERBAND_TRACK_VIEWS=true \\\nCOVERBAND_TRACK_TRANSLATIONS=true \\\nCOVERBAND_TRACK_ROUTES=true \\\nCOVERBAND_VERBOSE=true \\\nbundle exec rails s\n```\n\n**Optimized for Large Applications**\n```bash\nCOVERBAND_HASH_STORE=true \\\nCOVERBAND_PAGER=true \\\nbundle exec rails s\n```\n\n## Storage Options\n\n### Default Redis Store\nGood for most applications. Stores coverage data in Redis sorted sets.\n\n```ruby\n# Automatically configured based on Redis URL\n```\n\n### HashRedisStore (Recommended for Production)\nBetter performance for applications with 1000+ files.\n\n```bash\nCOVERBAND_HASH_STORE=true bundle exec rails s\n```\n\n### File Store\nStore coverage locally without Redis (development only).\n\n```ruby\n# In config/coverband.rb\nconfig.store = Coverband::Adapters::FileStore.new('/tmp/coverband_data')\n```\n\n## Performance Benchmarking\n\nThis demo includes comprehensive benchmarking tools.\n\n### Coverage Report Performance\n\nMeasure how long it takes to generate the coverage page:\n\n```bash\n# Basic benchmark\nCOVERBAND_DISABLE_AUTO_START=true bundle exec rake coverband_benchmark\n\n# With HashRedisStore\nCOVERBAND_DISABLE_AUTO_START=true COVERBAND_HASH_STORE=true bundle exec rake coverband_benchmark\n\n# Single file detail view\nCOVERBAND_DISABLE_AUTO_START=true bundle exec rake coverband_benchmark_single_file\n```\n\n### Runtime Overhead\n\nMeasure the performance impact on your application:\n\n```bash\n# With Coverband\nbundle exec rake runtime_overhead\n\n# Without Coverband (for comparison)\nCOVERBAND_DISABLE_AUTO_START=true bundle exec rake runtime_overhead\n```\n\n### Scale Testing\n\nGenerate many files to test performance with large codebases:\n\n```bash\n# Generate 1000 test files\nFILE_COUNT=1000 bundle exec rake generate_files\n\n# Execute them to create coverage data\nFILE_COUNT=1000 bundle exec rake execute_files\n\n# Run benchmark\nCOVERBAND_DISABLE_AUTO_START=true bundle exec rake coverband_benchmark\n```\n\n### Network Latency Simulation\n\nThe benchmarks use [Toxiproxy](https://github.com/Shopify/toxiproxy) to simulate network latency:\n\n```bash\n# Install toxiproxy\nbrew install toxiproxy  # macOS\n\n# Start toxiproxy\ntoxiproxy-server\n\n# Run benchmarks (automatically applies latency)\nbundle exec rake coverband_benchmark\n```\n\n## Memory Profiling\n\nUnderstand Coverband's memory footprint and optimize usage.\n\n### Memory Profile\n\nGet current memory statistics:\n\n```bash\nbundle exec rake memory_profile\n```\n\n### Memory Comparison\n\nCompare memory usage with and without Coverband:\n\n```bash\n# With Coverband\nbundle exec rake memory_profile\n\n# Without Coverband\nCOVERBAND_DISABLE_AUTO_START=true bundle exec rake memory_profile\n```\n\n### Request Memory Profile\n\nProfile memory during simulated requests:\n\n```bash\nbundle exec rake memory_request_profile\n```\n\n### Redis Memory Usage\n\nCheck how much Redis memory Coverband is using:\n\n```bash\nbundle exec rake redis_memory_usage\n```\n\n## Testing\n\nThis demo includes a comprehensive test suite that serves dual purposes:\n1. **Verify** the demo application works correctly\n2. **Document** Coverband usage through executable examples\n\n### Run All Tests\n\n```bash\nbundle exec rails test\n```\n\n### Run Coverband Documentation Tests Only\n\nThe `test/coverband/` directory contains tests that demonstrate how to use each Coverband feature:\n\n```bash\n# All Coverband feature tests\nbundle exec rails test test/coverband/\n\n# Specific feature tests\nbundle exec rails test test/coverband/configuration_test.rb\nbundle exec rails test test/coverband/view_tracking_test.rb\nbundle exec rails test test/coverband/translation_tracking_test.rb\nbundle exec rails test test/coverband/route_tracking_test.rb\nbundle exec rails test test/coverband/storage_test.rb\nbundle exec rails test test/coverband/integration_test.rb\nbundle exec rails test test/coverband/performance_test.rb\nbundle exec rails test test/coverband/configuration_scenarios_test.rb\n```\n\n### Test Suite Overview\n\n| Test File | Purpose | Learn About |\n|-----------|---------|-------------|\n| `configuration_test.rb` | Basic configuration | How to configure Coverband |\n| `view_tracking_test.rb` | View tracking | Tracking rendered views and partials |\n| `translation_tracking_test.rb` | I18n tracking | Tracking translation key usage |\n| `route_tracking_test.rb` | Route tracking | Monitoring endpoint access |\n| `storage_test.rb` | Storage backends | RedisStore vs HashRedisStore vs FileStore |\n| `integration_test.rb` | Complete workflows | Real-world usage scenarios |\n| `performance_test.rb` | Performance impact | Measuring overhead and optimization |\n| `configuration_scenarios_test.rb` | Real-world configs | Production, dev, API, etc. setups |\n\n### Using Tests as Learning Resources\n\nEach test file includes:\n- Detailed comments explaining features\n- Real-world use case examples\n- Configuration code snippets\n- Best practices and tips\n- Common pitfalls and solutions\n\n**Example**: To learn about view tracking:\n\n```bash\n# Read the test file for explanations\ncat test/coverband/view_tracking_test.rb\n\n# Run the tests to see it work\nbundle exec rails test test/coverband/view_tracking_test.rb -v\n```\n\nSee [TEST_DOCUMENTATION.md](TEST_DOCUMENTATION.md) for detailed information about the test suite and how to use it as living documentation.\n\n### Run System Tests\n\n```bash\nbundle exec rails test:system\n```\n\n### Code Style and Quality\n\nThis demo uses RuboCop for code style enforcement:\n\n```bash\n# Check code style\nbundle exec rubocop\n\n# Auto-fix issues\nbundle exec rubocop --auto-correct-all\n```\n\n✅ **Status**: All tests passing (97 tests, 218 assertions), RuboCop clean (0 offenses)\n\nSee [TESTING_AND_STYLE.md](TESTING_AND_STYLE.md) for detailed information about testing and code style standards.\n\n## Integrating Coverband Into Your App\n\n### Step 1: Add to Gemfile\n\n```ruby\ngem 'coverband'\n```\n\n### Step 2: Install\n\n```bash\nbundle install\n```\n\n### Step 3: Configure\n\nCreate `config/coverband.rb`:\n\n```ruby\nCoverband.configure do |config|\n  config.store = Coverband::Adapters::RedisStore.new(\n    Redis.new(url: ENV['REDIS_URL'] || 'redis://localhost:6379')\n  )\n\n  # Optional: Enable additional tracking\n  config.track_views = true\n  config.track_translations = true\n  config.track_routes = true\n\n  # Production settings\n  config.background_reporting_sleep_seconds = 300  # Report every 5 minutes\n  config.reporting_wiggle = 30  # Random delay to avoid thundering herd\nend\n```\n\n### Step 4: Mount Web Interface\n\nIn `config/routes.rb`:\n\n```ruby\n# Protect this route in production!\nauthenticate :user, lambda { |u| u.admin? } do\n  mount Coverband::Reporters::Web.new, at: '/coverage'\nend\n```\n\n### Step 5: Deploy and Monitor\n\nDeploy your app and start collecting coverage data. Visit `/coverage` to view reports.\n\n## Production Best Practices\n\n### Performance Optimization\n\n1. **Use HashRedisStore** for better performance with large codebases\n2. **Increase reporting interval** to reduce overhead: `config.background_reporting_sleep_seconds = 300`\n3. **Disable unused trackers** if you don't need them\n4. **Ignore vendor code** to reduce tracking: `config.ignore = ['vendor/', 'node_modules/']`\n\n### Memory Management\n\n1. **Monitor Redis memory** usage regularly\n2. **Clear old data** periodically: `Coverband.configuration.store.clear!`\n3. **Use paged reporting** for large apps: `config.paged_reporting = true`\n\n### Security\n\n1. **Protect the web interface** with authentication\n2. **Use environment-specific configs** to disable in test\n3. **Monitor performance impact** in production\n\n## Troubleshooting\n\n### High Memory Usage\n\n- Check how many files are being tracked\n- Verify ignore patterns are working\n- Consider using paged reporting\n- Increase reporting interval\n\n### Slow Coverage Reports\n\n- Switch to HashRedisStore\n- Enable paged reporting\n- Clear old data\n- Check Redis latency\n\n### Missing Coverage Data\n\n- Ensure Redis is running and accessible\n- Check `background_reporting_sleep_seconds` setting\n- Verify code is being executed\n- Check for errors in Rails logs\n\n## Additional Resources\n\n- [Coverband GitHub Repository](https://github.com/danmayer/coverband)\n- [Coverband Documentation](https://github.com/danmayer/coverband#coverband)\n- [Coverage Report Demo](http://localhost:3000/coverage) (when running locally)\n\n## Contributing\n\nIssues and pull requests welcome! Please test your changes with this demo app before submitting.\n\n## License\n\nThis demo application is MIT licensed. Coverband itself is also MIT licensed.\n\n## Dependencies\n\n- **Ruby**: 3.4.7\n- **Rails**: 7.1.3\n- **Redis**: 6.0+\n- **Coverband**: Latest from `../coverband` (for development)\n\n## Support\n\nFor questions or issues:\n\n1. Check the [Coverband documentation](https://github.com/danmayer/coverband)\n2. Review the [demo pages](http://localhost:3000/demo) for examples\n3. Open an issue on the [Coverband repo](https://github.com/danmayer/coverband/issues)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanmayer%2Fcoverband_rails_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanmayer%2Fcoverband_rails_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanmayer%2Fcoverband_rails_example/lists"}