Class: SimpleCov::Configuration::CoverageCriterion

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/configuration/coverage.rb

Overview

Receiver for a ‘coverage <criterion> 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.

Instance Method Summary collapse

Constructor Details

#initialize(config, criterion) ⇒ CoverageCriterion

Returns a new instance of CoverageCriterion.



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

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

Instance Method Details

#exact(percent) ⇒ Object

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



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

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

#maximum(percent) ⇒ Object

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



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

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

#maximum_drop(percent) ⇒ Object

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



149
150
151
# 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) ⇒ Object

Overall (suite-wide) minimum for this criterion.



132
133
134
# 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) ⇒ Object

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.



156
157
158
# 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:) ⇒ Object

Per-group minimum for the named group (defined via ‘group`).



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

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

#primaryObject

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



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

def primary
  @config.primary_coverage(@criterion)
end