Daniel Irvine on building software
Code coverage with SimpleCov in under 2 minutes
10 June 2014
I was seriously impressed today with SimpleCov, a code coverage test tool for Ruby. I went from wanting to have coverage to actually having the numbers in under 2 minutes. This makes me so happy.
Here’s how to do it if you’re using RSpec with a standard project setup.
gem install Simplecov
- Open your
spec_helper.rbfile (or whatever your RSpec entry point is) and enter the following at the very top. The call to
SimpleCov.startmust appear before any of the requires for your own code.
require 'simplecov' SimpleCov.start do add_filter spec/ end
.gitignorefile at your repository root.
coverage/index.htmlto view your coverage statistics.
It really couldn’t be simpler.