test/helper.rb
# Low-level deprecation handler. Use the more convenient version when possible.
# a_group => :expect_warn
# a_group => :expect_fail
# a_group => :expect_ignore
# a_group => :expect_something
# a_group => :tolerate # No opinion
# all => ... # Any of the 5 values above
# all_others => ... # Any of the 5 values above
Low-level deprecation handler. Use the more convenient version when possible.
Low - level deprecation handler . Use the more convenient version when possible .
def handle_deprecations(opts_in, &block)
  opts = opts_in.dup
  opts[:all_others] = opts.delete(:all) if opts.key?(:all) && opts.count == 1
  expectations = {}
  expectations[:all_others] = opts.delete(:all_others) || :tolerate
  expectations.merge!(opts)
  known_group_names = Inspec::Deprecation::ConfigFile.new.groups.keys
  known_group_names.each do |group_name|
    next if opts.key?(group_name)
    expectations[group_name] = expectations[:all_others]
  end
  expectations.each do |group_name, expectation|
    inst = Inspec::Deprecation::Deprecator.any_instance
    case expectation
    when :tolerate
      inst.stubs(:handle_deprecation).with(group_name, anything, anything)
    when :expect_something
      inst.stubs(:handle_deprecation).with(group_name, anything, anything).at_least_once
    when :expect_warn
      inst.stubs(:handle_warn_action).with(group_name, anything).at_least_once
    when :expect_fail
      inst.stubs(:handle_fail_control_action).with(group_name, anything).at_least_once
    when :expect_ignore
      inst.stubs(:handle_ignore_action).with(group_name, anything).at_least_once
    when :expect_exit
      inst.stubs(:handle_exit_action).with(group_name, anything).at_least_once
    end
  end
  yield
end
def handle_deprecations ( opts_in , & block ) opts = opts_in . dup opts [ :all_others ] = opts . delete ( :all ) if opts . key? ( :all ) && opts . count == 1 expectations = { } expectations [ :all_others ] = opts . delete ( :all_others ) || :tolerate expectations . merge! ( opts ) known_group_names = Inspec :: Deprecation :: ConfigFile . new . groups . keys known_group_names . each do | group_name | next if opts . key? ( group_name ) expectations [ group_name ] = expectations [ :all_others ] end expectations . each do | group_name , expectation | inst = Inspec :: Deprecation :: Deprecator . any_instance case expectation when :tolerate inst . stubs ( :handle_deprecation ) . with ( group_name , anything , anything ) when :expect_something inst . stubs ( :handle_deprecation ) . with ( group_name , anything , anything ) . at_least_once when :expect_warn inst . stubs ( :handle_warn_action ) . with ( group_name , anything ) . at_least_once when :expect_fail inst . stubs ( :handle_fail_control_action ) . with ( group_name , anything ) . at_least_once when :expect_ignore inst . stubs ( :handle_ignore_action ) . with ( group_name , anything ) . at_least_once when :expect_exit inst . stubs ( :handle_exit_action ) . with ( group_name , anything ) . at_least_once end end yield end
Low-level deprecation handler.
Low - level deprecation handler .
# Determine the default expectation # Expand the list of deprecation groups given # Wire up Insepc.deprecator accordingly using mocha stubbing
opts_in
<not_specific>
block
<not_specific>