Published on
1 min read

Check Test Coverage With SimpleCov Gem

Authors

SimpleCov is a code coverage analysis tool for Ruby. It uses Ruby's built-in Coverage library to gather data but provides a clean API to filter, group, merge, format, and display those results.

Getting started

Add SimpleCov to your Gemfile:

gem 'simplecov', :require => false, :group => :test

Load and launch SimpleCov at the very top of your spec_helper.rb (or test_helper.rb):

require 'simplecov'
SimpleCov.start 'rails' if ENV["COVERAGE"]

SimpleCov will only run if you execute your tests with the COVERAGE=true environment variable:

COVERAGE=true bundle exec rspec

Run your tests, and then open coverage/index.html in your browser to see the detailed report.

SimpleCov Overview
TwitterLinkedInHacker News