Class: SimpleCov::ExitCodes::MaximumCoverageDropCheck

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

Instance Method Summary collapse

Constructor Details

#initialize(result, maximum_coverage_drop) ⇒ MaximumCoverageDropCheck

Returns a new instance of MaximumCoverageDropCheck.



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

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

Instance Method Details

#exit_codeObject



25
26
27
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 25

def exit_code
  SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
end

#failing?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 11

def failing?
  return false unless maximum_coverage_drop && last_run

  coverage_diff > maximum_coverage_drop
end

#reportObject



17
18
19
20
21
22
23
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 17

def report
  $stderr.printf(
    "Coverage has dropped by %<drop_percent>.2f%% since the last time (maximum allowed: %<max_drop>.2f%%).\n",
    drop_percent: coverage_diff,
    max_drop: maximum_coverage_drop
  )
end