class FilterTable::ExceptionCatcher

Public Class Methods

new(original_resource, original_exception) click to toggle source
# File lib/inspec/utils/filter.rb, line 8
def initialize(original_resource, original_exception)
  @original_resource = original_resource
  @original_exception = original_exception
end

Public Instance Methods

inspect()
Alias for: to_s
method_missing(*) click to toggle source

Capture message chains and return `ExceptionCatcher` objects

# File lib/inspec/utils/filter.rb, line 32
def method_missing(*)
  self
end
resource_exception_message() click to toggle source
# File lib/inspec/utils/filter.rb, line 27
def resource_exception_message
  @original_exception.message
end
resource_failed?() click to toggle source

This method is called via the runner and signals RSpec to output a block showing why the resource failed. This prevents the resource from being added to the test collection and being evaluated.

# File lib/inspec/utils/filter.rb, line 23
def resource_failed?
  @original_exception.is_a?(Inspec::Exceptions::ResourceFailed)
end
resource_skipped?() click to toggle source

This method is called via the runner and signals RSpec to output a block showing why the resource was skipped. This prevents the resource from being added to the test collection and being evaluated.

# File lib/inspec/utils/filter.rb, line 16
def resource_skipped?
  @original_exception.is_a?(Inspec::Exceptions::ResourceSkipped)
end
respond_to?(_method, include_all = false) click to toggle source

RSpec will check the object returned to see if it responds to a method before calling it. We need to fake it out and tell it that it does. This allows it to skip past that check and fall through to method_missing

# File lib/inspec/utils/filter.rb, line 39
def respond_to?(_method, include_all = false)
  true
end
to_ary() click to toggle source

Rspec is not able to convert FilterTable::ExceptionCatcher issue github.com/inspec/inspec/issues/5369 which result into not showing actual exception message this allows to convert it properly.

# File lib/inspec/utils/filter.rb, line 50
def to_ary
  [ to_s ]
end
to_s() click to toggle source
# File lib/inspec/utils/filter.rb, line 43
def to_s
  "#{@original_resource} (#{@original_exception.message})"
end
Also aliased as: inspect