Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A Ruby production code coverage tool designed to assist you in identifying unused code.

Notifications You must be signed in to change notification settings

cardinalblue/cover_rage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cover_rage

test

cover_rage is a Ruby code coverage tool designed to be simple and easy to use. It can be used not only for test coverage but also in production services to identify unused code.

Key features:

  1. Runs in continuous processes (e.g., Rails servers)

  2. Zero dependencies

  3. Supports forking and daemonization without additional setup

Installation

gem install cover_rage

Setup

require 'cover_rage'

AND THAT’S IT!

No rack middleware, no fork callbacks, no configuration files, and no additional setup required.

It starts collecting coverage data and periodically writes to ./cover_rage.pstore.

To change the store type and location, refer to COVER_RAGE_STORE_URL below.

To export results to HTML later, run cover_rage.

Quick Start

cat >main.rb <<RUBY
s = 0
10.times do |x|
  s += x
end
fork
if s == 45
  p :ok
else
  p :ng
end
RUBY

gem install cover_rage
ruby -r cover_rage main.rb
cover_rage > cover_rage.html
demo

Integration with Ruby on Rails

No additional setup is required because Rails loads gems automatically, but you can customize the behavior by updating Gemfile.

To run cover_rage only in the test environment:

Gemfile
gem 'cover_rage', group: :test

To manually start cover_rage:

Gemfile
gem 'cover_rage', require: false
config/boot.rb
require 'cover_rage'

Exporting Results

cover_rage --format html

Run cover_rage -h for more information.

Environment Variables

  1. COVER_RAGE_STORE_URL

    Available URL schemes:

    1. pstore://ABSOLUTE_PATH_TO_PSTORE_FILE

    2. redis://REDIS_HOST

    3. sqlite://ABSOLUTE_PATH_TO_SQLITE_DB_FILE

    Ensure you have the necessary gems (e.g., sqlite3, redis) installed to use other store types.

    Defaults to pstore:$(pwd)/cover_rage.pstore.

  2. COVER_RAGE_INTERVAL

    It sets The interval in seconds between each write to the store.

    Defaults to 60.

  3. COVER_RAGE_PATH_PREFIX

    cover_rage will only record files that match the specified prefix.

    Defaults to Rails.root if the Rails constant is defined; otherwise, defaults to Dir.pwd.

About

A Ruby production code coverage tool designed to assist you in identifying unused code.

Topics

Resources

Stars

Watchers

Forks