cover_me

An RCov-esque coverage tool for Ruby 1.9

  • Owner: markbates/cover_me
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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":http://engineering.attinteractive.com/2010/08/code-coverage-in-ruby-1-9/ 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 ("BiddingForGood.com":http://www.biddingforgood.com), 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:

Now make sure to install the gem with Bundler:

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

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:

h2. Configuration

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

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

Main metrics

Overview
Name With Ownermarkbates/cover_me
Primary LanguageRuby
Program languageRuby (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2010-08-13 14:45:07
Pushed At2023-01-18 19:32:56
Last Commit At2012-01-31 12:11:14
Release Count0
用户参与
Stargazers Count203
Watchers Count5
Fork Count17
Commits Count71
Has Issues Enabled
Issues Count56
Issue Open Count26
Pull Requests Count13
Pull Requests Open Count5
Pull Requests Close Count4
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private