Skip to content

Instantly share code, notes, and snippets.

@sbleon
Created December 17, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbleon/3726197109eda6e7fd82 to your computer and use it in GitHub Desktop.
Save sbleon/3726197109eda6e7fd82 to your computer and use it in GitHub Desktop.
# Place all this at the beginning of your spec_helper.rb to avoid sending
# incorrect coverage data to Code Climate.
require 'codeclimate-test-reporter'
SimpleCov.start 'rails' do
# We always want to run the HTML coverage formatter.
formatters = [ SimpleCov::Formatter::HTMLFormatter ]
# Code Climate records the first coverage data it is sent for any single
# commit, and then ignores future reports. If you're running a single spec,
# this will result in the reporting of erroneously low test coverage.
# So, only send them coverage data if all specs are being run together.
running_all_specs = !ARGV.last.match(/_spec\.rb/)
if running_all_specs
formatters << CodeClimate::TestReporter::Formatter
end
formatter SimpleCov::Formatter::MultiFormatter.new(formatters)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment