123456789_123456789_123456789_123456789_123456789_

Class: SimpleCov::Configuration::CoverageCriterion

Relationships & Source Files
Inherits: Object
Defined in: lib/simplecov/configuration/coverage.rb

Overview

Receiver for a coverage do ... end block. Each verb writes a threshold for the single criterion the block configures, so the value is always a plain percentage (minimum_per_file 100 is unambiguous) and the syntax is identical across line, branch, and method coverage.

Class Method Summary

Instance Method Summary

Constructor Details

.new(config, criterion) ⇒ CoverageCriterion

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 126

def initialize(config, criterion)
  @config = config
  @criterion = criterion
end

Instance Method Details

#exact(percent)

Pin coverage to an exact figure (sets both #minimum and #maximum).

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 143

def exact(percent)
  minimum(percent)
  maximum(percent)
end

#maximum(percent)

Overall maximum: fails the build if coverage rises above it. Paired with #minimum (or via #exact) this pins coverage so an unexpected jump fails.

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 138

def maximum(percent)
  @config.send(:store_overall_threshold, :maximum_coverage, @criterion, percent)
end

#maximum_drop(percent)

Maximum allowed drop between runs (maximum_drop 0 refuses any drop).

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 149

def maximum_drop(percent)
  @config.send(:store_overall_threshold, :maximum_coverage_drop, @criterion, percent)
end

#minimum(percent)

Overall (suite-wide) minimum for this criterion.

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 132

def minimum(percent)
  @config.send(:store_overall_threshold, :minimum_coverage, @criterion, percent)
end

#minimum_per_file(percent, only: nil)

Per-file minimum. With no only:, sets the default applied to every file; with only: (a String path or Regexp), overrides that default for the matching files.

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 156

def minimum_per_file(percent, only: nil)
  @config.send(:store_minimum_per_file, @criterion, percent, only)
end

#minimum_per_group(percent, only:)

Per-group minimum for the named group (defined via SimpleCov::Configuration#group).

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 161

def minimum_per_group(percent, only:)
  @config.send(:store_minimum_per_group, @criterion, percent, only)
end

#primary

Make this criterion the report's primary (leading) criterion.

[ GitHub ]

  
# File 'lib/simplecov/configuration/coverage.rb', line 166

def primary
  @config.primary_coverage(@criterion)
end