Class: Inspec::Feature::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/feature/runner.rb

Class Method Summary collapse

Class Method Details

.with_feature(feature_name, opts = {}, &feature_implementation) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/inspec/feature/runner.rb', line 4

def self.with_feature(feature_name, opts = {}, &feature_implementation)
  config = opts[:config] || Inspec::Feature::Config.new
  logger = opts[:logger] || Inspec::Log

  # Emit log message saying we're running a feature
  logger.debug("Prepping to run feature '#{feature_name}'")

  # Validate that the feature is recognized
  feature = config[feature_name]
  unless feature
    logger.warn "Unrecognized feature name '#{feature_name}'"
  end

  # If the feature is not recognized
  # If the feature has no env_preview flag set in config
  # If the feature is previewable
  if feature.nil? || feature&.no_preview? || feature&.previewable?
    yield feature_implementation
  end
end