Skip to content

Commit

Permalink
Merge pull request #24 from aldesantis/code-coverage
Browse files Browse the repository at this point in the history
Add support for Codecov
  • Loading branch information
kennyadsl authored Nov 4, 2019
2 parents 2de3eee + 0626cac commit b4f5739
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions lib/solidus_support/extension/coverage.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions solidus_support.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b4f5739

Please sign in to comment.