Need help with cover_me?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

205 Stars 19 Forks MIT License 71 Commits 31 Opened issues


An RCov-esque coverage tool for Ruby 1.9

Services available


Need anything else?

Contributors list

h1. CoverMe - Code Coverage for Ruby 1.9

Ruby 1.9(.2) is an amazing language to develop applications in. It's faster, more powerful, cleaner, and a huge improvement over Ruby 1.8.x. Because of those reasons every Ruby developer should move to this exciting new version of our language.

When making a move of this size it's important to have the right tools to help us along. Unfortunately, one of the most useful tools as a Ruby developer, RCov, does not work with Ruby 1.9.

RCov, for those unfamiliar analyzes your code and tells you which part of your code was not executed. This is INCREDIBLY useful when hooked up to your test suite. While, it's not the only metric you should use when determining how good your test coverage it, it certainly is a great first step to point out exactly which parts of your code haven't been touched at all!

Enter CoverMe.

h2. History

While working on a Ruby 1.9/Rails 3 project, and loving everything about it (except for the lack of RCov), I came across a "post": by Aaron Patterson (of Nokogiri fame). In this post he quickly outlined a very basic coverage tool using the new built-in Coverage module in Ruby 1.9.

After spending a morning playing with it, I was quickly able to grow the idea into something useful for the project. Later that day the company I was consulting for ("":, and in particular their chief architect, Stuart Garner, told me to take a day or two and clean it up and release it for the world to use, and so here it is.

h2. Features

h3. Index Page

  • Sortable column headers (File, Lines, Lines of Code, Tested %).
  • Searching/filtering by file name.
  • Filtering by coverage percent.
  • Color coded list of files to quickly see which ones are 100% covered, > 90% covered, or less than 90% covered.
  • Large color coded average coverage percent, for quick reference.

h3. Detail Page

  • Line by line coverage report
  • Color coded lines to quickly see which lines where executed and which ones were not.
  • Side by side viewing with the corresponding test/spec file (if one exists).

h2. Use

CoverMe is pretty easy to use, and has been tested with Ruby 1.9.2 and Rails 3. First, add CoverMe to your Gemfile:

  gem 'cover_me', '>= 1.2.0', :group => :test

Now make sure to install the gem with Bundler:

  $ bundle install

All that's left now is to require it as the first line of your 'spechelper.rb' or 'testhelper.rb' file:

  require 'cover_me'

Now the next time your run your test suite it will create a series of HTML files in the coverage folder at the root of your project. Open coverage/index.html and you're off and running.

h3. Rails 3

If you are using CoverMe with Rails 3 run the following to get the cover me Rake task:

  $ rails g cover_me:install

h2. Configuration

CoverMe is easily configurable, under the covers it uses the "Configatron": library. Here are a few quick config options you might want to play with:

  CoverMe.config do |c|
    # where is your project's root:
    c.project.root # => "Rails.root" (default)

    # what files are you interested in coverage for:
    c.file_pattern # => [
    ] (default)

    # what files do you want to explicitly exclude from coverage
    c.exclude_file_patterns # => [] (default)

    # where do you want the HTML generated:
    c.html_formatter.output_path # => File.join(CoverMe.config.project.root, 'coverage') (default)

    # what do you want to happen when it finishes:
    c.at_exit # => {
      if CoverMe.config.formatter == CoverMe::HtmlFormatter
        index = File.join(CoverMe.config.html_formatter.output_path, 'index.html')
        if File.exists?(index)
          `open #{index}`
    } (default)

h2. Contributors

  • Mark Bates
  • Andrea Campi
  • KITAITI Makoto
  • Alex Crichton
  • Leif Bladt
  • Will Marshall
  • Matthew Albright
  • Josef Sin
  • Lasse Koskela
  • Stephen Delano
  • George Anderson
  • Rob Zolkos
  • jmthomas

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.