Neon Tsunami

Incorrect coverage reporting on Heroku CI

August 01, 2017

I've recently started using Heroku CI to test my Heroku apps on Rails, but ran into a strange issue where Simplecov was reporting my code coverage at around 18%, where locally it was 100%. After a little bit of research I discovered the same sort of issue occured on Travis CI likely because of the location where it installed the app dependencies.

Luckily, it's an easy fix. Just adjust your Simplecov configuration in your spec_helper.rb - by filtering out the vendor directory third party code won't be included in your code coverage stats.

require 'simplecov'
SimpleCov.start :rails do
  add_filter 'vendor'
end

A blog about Laravel & Rails, written by Dwight Watson.