Class: SimpleCov::ExitCodes::MinimumOverallCoverageCheck

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

Instance Method Summary collapse

Constructor Details

#initialize(result, minimum_coverage) ⇒ MinimumOverallCoverageCheck

Returns a new instance of MinimumOverallCoverageCheck.



6
7
8
9
# File 'lib/simplecov/exit_codes/minimum_overall_coverage_check.rb', line 6

def initialize(result, minimum_coverage)
  @result = result
  @minimum_coverage = minimum_coverage
end

Instance Method Details

#exit_codeObject



26
27
28
# File 'lib/simplecov/exit_codes/minimum_overall_coverage_check.rb', line 26

def exit_code
  SimpleCov::ExitCodes::MINIMUM_COVERAGE
end

#failing?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/simplecov/exit_codes/minimum_overall_coverage_check.rb', line 11

def failing?
  minimum_violations.any?
end

#reportObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/simplecov/exit_codes/minimum_overall_coverage_check.rb', line 15

def report
  minimum_violations.each do |violation|
    $stderr.printf(
      "%<criterion>s coverage (%<covered>.2f%%) is below the expected minimum coverage (%<minimum_coverage>.2f%%).\n",
      covered: SimpleCov.round_coverage(violation.fetch(:actual)),
      minimum_coverage: violation.fetch(:minimum_expected),
      criterion: violation.fetch(:criterion).capitalize
    )
  end
end