Class: SimpleCov::ExitCodes::MinimumCoverageByFileCheck

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

Instance Method Summary collapse

Constructor Details

#initialize(result, minimum_coverage_by_file) ⇒ MinimumCoverageByFileCheck

Returns a new instance of MinimumCoverageByFileCheck.



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

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

Instance Method Details

#exit_codeObject



26
27
28
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_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_coverage_by_file_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_coverage_by_file_check.rb', line 15

def report
  minimum_violations.each do |violation|
    $stderr.printf(
      "%<criterion>s coverage by file (%<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