Class: SimpleCov::RSpec
- Inherits:
-
Object
- Object
- SimpleCov::RSpec
- Defined in:
- lib/simplecov-rspec.rb,
lib/simplecov-rspec/uncovered_report.rb,
lib/simplecov-rspec/list_uncovered_option.rb,
lib/simplecov-rspec/described_source_files.rb,
lib/simplecov-rspec/list_uncovered_files_option.rb
Overview
Configure SimpleCov to enforce coverage thresholds for RSpec, on top of what SimpleCov itself already provides.
SimpleCov (>= 1.0) can already enforce minimum_coverage for line, branch, and
method coverage, and will exit with a non-zero status when a threshold is missed.
This gem layers four things SimpleCov doesn't do on its own:
- Suppresses coverage failures when RSpec is run in dry-run mode (e.g. from an IDE).
- Lists (or summarizes) the individual uncovered lines, branches, and methods.
- Scopes that listing to the files you name, or to the code the run described.
- Lets all of the above be overridden from the environment, for CI.
Simply add the line SimpleCov::RSpec.start in place of SimpleCov.start in
the project's spec_helper.rb. This line must appear before the project is
required.
Defined Under Namespace
Modules: DescribedSourceFiles, ListUncoveredFilesOption, ListUncoveredOption Classes: UncoveredReport
Instance Attribute Summary collapse
-
#env ⇒ Hash
readonly
private
The environment variables consulted for overrides.
-
#simplecov_module ⇒ Module
readonly
private
The SimpleCov module being configured.
-
#start_config_block ⇒ Proc?
readonly
private
A configuration block passed through to
SimpleCov.start.
Class Method Summary collapse
-
.described_source_files ⇒ Array<String>
The source files defining the classes this RSpec run described.
-
.start(minimum_coverage: { line: 100 }, fail_on_low_coverage: true, list_uncovered: false, list_uncovered_detail: true, rspec_dry_run: ::RSpec.configuration.dry_run?, env: ENV, &start_config_block) ⇒ Void
Configure and start SimpleCov for RSpec.
Instance Attribute Details
#env ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The environment variables consulted for overrides
|
|
# File 'lib/simplecov-rspec.rb', line 48
|
#simplecov_module ⇒ Module (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The SimpleCov module being configured
|
|
# File 'lib/simplecov-rspec.rb', line 48
|
#start_config_block ⇒ Proc? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A configuration block passed through to SimpleCov.start
|
|
# File 'lib/simplecov-rspec.rb', line 48
|
Class Method Details
.described_source_files ⇒ Array<String>
The source files defining the classes this RSpec run described
What list_uncovered_files: :described scopes to. Call it directly to build a
scope of your own — to add files the run touches but does not describe, say:
list_uncovered_files: -> { SimpleCov::RSpec.described_source_files + ['lib/support.rb'] }
Only meaningful once the run has defined its examples, which is why it is passed
as a callable rather than called at start.
A described class contributes nothing when it is anonymous, defined in C, or no longer reachable by name, since there is no source file to report on.
199 |
# File 'lib/simplecov-rspec.rb', line 199 def self.described_source_files = DescribedSourceFiles.call |
.start(minimum_coverage: { line: 100 }, fail_on_low_coverage: true, list_uncovered: false, list_uncovered_detail: true, rspec_dry_run: ::RSpec.configuration.dry_run?, env: ENV, &start_config_block) ⇒ Void
Configure and start SimpleCov for RSpec
174 |
# File 'lib/simplecov-rspec.rb', line 174 def self.start(...) = new(...).send(:start) |