From 0626cac0c91c257e124fb55c9fcc2bd8236d7b3f Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Thu, 31 Oct 2019 17:11:23 +0100 Subject: [PATCH] Add support for Codecov --- README.md | 20 ++++++++++++++++++++ lib/solidus_support/extension/coverage.rb | 16 ++++++++++++++++ solidus_support.gemspec | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 lib/solidus_support/extension/coverage.rb diff --git a/README.md b/README.md index ff42786..f8a7e0a 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,26 @@ in all extensions. It is also requireable as a stand-alone helper with: require "solidus_support/extension/spec_helper" ``` +### Coverage Collection + +The gem also includes a SimpleCov configuration that will send your test +coverage information directly to Codecov.io. Simply add this at the top +of your `spec/spec_helper.rb`: + +```ruby +require "solidus_support/extension/coverage" +``` + +**Note: Make sure to add this at the VERY TOP of your spec_helper, +otherwise you'll get skewed coverage reports!** + +If your extension is in a public repo and being tested on Travis or +CircleCI, there's nothing else you need to do - you'll get coverage +reports for free! + +If your setup is more complex, look at the [SimpleCov](https://github.com/colszowka/simplecov) +and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs. + ## Development After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/lib/solidus_support/extension/coverage.rb b/lib/solidus_support/extension/coverage.rb new file mode 100644 index 0000000..cd234f4 --- /dev/null +++ b/lib/solidus_support/extension/coverage.rb @@ -0,0 +1,16 @@ +# A SimpleCov and Codecov configuration to track code coverage in your extension +# +# Include it AT THE TOP of your spec/spec_helper.rb: +# +# require 'solidus_support/extension/coverage' +# +# Note that things may not work properly if you don't include this at the very top! +# + +require 'simplecov' +SimpleCov.start 'rails' + +if ENV['CI'] + require 'codecov' + SimpleCov.formatter = SimpleCov::Formatter::Codecov +end diff --git a/solidus_support.gemspec b/solidus_support.gemspec index d03681a..6bc253d 100644 --- a/solidus_support.gemspec +++ b/solidus_support.gemspec @@ -23,5 +23,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop' spec.add_development_dependency 'rubocop-rspec' spec.add_development_dependency 'solidus_core' + spec.add_dependency 'capybara-screenshot' + spec.add_dependency 'codecov' end