Class: SimpleCov::ExitCodes::MinimumCoverageByFileCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb

Overview

Fails when any individual file falls below the configured minimum coverage for any criterion.

Instance Method Summary collapse

Constructor Details

#initialize(result, minimum_coverage_by_file, overrides = {}) ⇒ MinimumCoverageByFileCheck

Returns a new instance of MinimumCoverageByFileCheck.



8
9
10
11
12
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 8

def initialize(result, minimum_coverage_by_file, overrides = {})
  @result = result
  @minimum_coverage_by_file = minimum_coverage_by_file
  @overrides = overrides
end

Instance Method Details

#exit_codeObject



31
32
33
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 31

def exit_code
  SimpleCov::ExitCodes::MINIMUM_COVERAGE
end

#failing?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 14

def failing?
  violations.any?
end

#reportObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 18

def report
  violations.each do |violation|
    warn format(
      "%<criterion>s coverage by file (%<actual>s) is below the expected minimum coverage " \
      "(%<expected>.2f%%) in %<filename>s.",
      criterion: violation.fetch(:criterion).capitalize,
      actual: SimpleCov::Color.colorize_percent(violation.fetch(:actual)),
      expected: violation.fetch(:expected),
      filename: violation.fetch(:project_filename)
    )
  end
end