Class: SimpleCov::RSpec::UncoveredReport Private

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-rspec/uncovered_report.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Formats the "uncovered lines/branches/methods" report printed after a run: either a full listing of every uncovered item, or a per-criterion count with a hint on how to see the details.

Constant Summary collapse

CRITERION_LABELS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Maps a coverage criterion to its [singular, plural] noun, for report formatting

{
  line: %w[line lines],
  branch: %w[branch branches],
  method: %w[method methods]
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(result:, criteria:, detail:, detail_env_var:, files: nil) ⇒ UncoveredReport

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.

Build a report for the given result, criteria, and detail level

Examples:

UncoveredReport.new(result: SimpleCov.result, criteria: [:line], detail: true, detail_env_var: 'X')

Parameters:

  • result (SimpleCov::Result)

    the SimpleCov result to report on

  • criteria (Array<Symbol>)

    which criteria (:line, :branch, :method) to report

  • detail (Boolean)

    list individual items, or just a count per criterion

  • detail_env_var (String)

    the ENV var name to suggest for switching to detail

  • files (Array<String>, nil) (defaults to: nil)

    absolute paths to report on, or nil for every file



28
29
30
31
32
33
34
# File 'lib/simplecov-rspec/uncovered_report.rb', line 28

def initialize(result:, criteria:, detail:, detail_env_var:, files: nil)
  @result = result
  @criteria = criteria
  @detail = detail
  @detail_env_var = detail_env_var
  @files = files
end

Instance Method Details

#to_sString

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 formatted report text, or an empty string if there is nothing to report

A scoped report (one where files is not nil) always produces text, even when every file it covers is fully covered. Silence there would be indistinguishable from a clean run of the whole suite, which is the opposite of what asking for a scope means.

Returns:

  • (String)


44
# File 'lib/simplecov-rspec/uncovered_report.rb', line 44

def to_s = files.nil? ? uncovered_text : scoped_text