Kettle::Soup::Cover
A Covered Kettle of SOUP (Software of Unknown Provenance)
The name is derived in part from the medical devices field, where this library is considered a package of SOUP.
It provides a one-line-configured, curated, opinionated, set of dependencies for Test Coverage.
Support My Open Source Development
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add kettle-soup-cover
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install kettle-soup-cover
Usage
In your spec/spec_helper.rb
, just prior to loading the library under test:
# This does not require "simplecov",
# because that has a side-effect of running `.simplecov`
require "kettle-soup-cover"
# Later in your spec setup, do this;
require "simplecov" if Kettle::Soup::Cover::COV_DO
In your .simplecov
file:
require "kettle/soup/cover/config"
SimpleCov.start # you could do this somewhere else, up to you, but you do have to do it
See Advanced Usage below for more info, but the simplest thing is to run all the coverage things, which is configured by default on CI. To replicate that locally you could:
CI=true bundle exec rake test # or whatever command you run for tests.
That's it!
Rakefile
You'll need to have your test
task defined.
If you use spec
instead, you can alias test
to spec
as follows:
desc "alias test task to spec"
task test: :spec
This gem provides a coverage
task.
It runs the test
task (see just above about that),
and opens the coverage results in a browser.
require "kettle-soup-cover"
Kettle::Soup::Cover.install_tasks
Filters
There are two built-in SimpleCov filters which can be loaded via Kettle::Soup::Cover.load_filters
.
You could use them like this:
SimpleCov.add_group("Too Long", Kettle::Soup::Cover::Filters::GtLineFilter.new(1000))
Advanced Usage
There are a number of ENV variables that control things within this gem. All of them can be found, along with their default values, in lib/kettle/soup/cover.rb.
Handy List of ENV Variables
Most are self explanatory. I tried to follow POLS, the principle of least surprise, so they mostly DWTFYT. Want to help improve this documentation? PRs are easy!
K_SOUP_COV_COMMAND_NAME
K_SOUP_COV_DEBUG
K_SOUP_COV_DIR
K_SOUP_COV_DO
K_SOUP_COV_FILTER_DIRS
K_SOUP_COV_FORMATTERS
K_SOUP_COV_MERGE_TIMEOUT
K_SOUP_COV_MIN_HARD
K_SOUP_COV_MIN_BRANCH
K_SOUP_COV_MIN_LINE
K_SOUP_COV_MULTI_FORMATTERS
K_SOUP_COV_PREFIX
K_SOUP_COV_USE_MERGING
K_SOUP_COV_VERBOSE
Additionally some of the included gems, like simplecov-console
,
have their own complete suite of ENV variables you can configure.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Code of Conduct
Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Contributing
See CONTRIBUTING.md.
Versioning
This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.
As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.
For example:
spec.add_dependency("kettle-soup-cover", "~> 1.0")
License
The gem is available as open source under the terms of the MIT License . See LICENSE for the official Copyright Notice.
- Copyright (c) 2023 [Peter H. Boling][peterboling] of Rails Bling