class FilterTable::ExceptionCatcher
Public Class Methods
# 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
Capture message chains and return `ExceptionCatcher` objects
# File lib/inspec/utils/filter.rb, line 32 def method_missing(*) self end
# File lib/inspec/utils/filter.rb, line 27 def resource_exception_message @original_exception.message end
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
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
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
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
# File lib/inspec/utils/filter.rb, line 43 def to_s "#{@original_resource} (#{@original_exception.message})" end