Class: Kitchen::Verifier::Inspec

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/verifier/inspec.rb

Overview

InSpec verifier for Kitchen.

Author:

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kitchen/verifier/inspec.rb', line 40

def call(state)
  logger.debug('Initialize InSpec')
  opts = runner_options(instance.transport, state)
  runner = ::Inspec::Runner.new(opts)

  # add each profile to runner
  tests = collect_tests
  tests.each { |target| runner.add_target(target, opts) }

  logger.debug("Running tests from: #{tests.inspect}")
  exit_code = runner.run
  return if exit_code == 0
  fail ActionFailed, "Inspec Runner returns #{exit_code}"
end