Class: FilterTable::ExceptionCatcher
- Inherits:
 - 
      Object
      
        
- Object
 - FilterTable::ExceptionCatcher
 
 
- Defined in:
 - lib/inspec/utils/filter.rb
 
Instance Method Summary collapse
- 
  
    
      #initialize(original_resource, original_exception)  ⇒ ExceptionCatcher 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ExceptionCatcher.
 - 
  
    
      #method_missing  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Capture message chains and return ‘ExceptionCatcher` objects.
 - #resource_exception_message ⇒ Object
 - 
  
    
      #resource_failed?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
This method is called via the runner and signals RSpec to output a block showing why the resource failed.
 - 
  
    
      #resource_skipped?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
This method is called via the runner and signals RSpec to output a block showing why the resource was skipped.
 - 
  
    
      #respond_to?(_method, include_all = false)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
RSpec will check the object returned to see if it responds to a method before calling it.
 - 
  
    
      #to_ary  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
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.
 - #to_s ⇒ Object (also: #inspect)
 
Constructor Details
#initialize(original_resource, original_exception) ⇒ ExceptionCatcher
Returns a new instance of ExceptionCatcher.
      8 9 10 11  | 
    
      # File 'lib/inspec/utils/filter.rb', line 8 def initialize(original_resource, original_exception) @original_resource = original_resource @original_exception = original_exception end  | 
  
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
Capture message chains and return ‘ExceptionCatcher` objects
      32 33 34  | 
    
      # File 'lib/inspec/utils/filter.rb', line 32 def method_missing(*) self end  | 
  
Instance Method Details
#resource_exception_message ⇒ Object
      27 28 29  | 
    
      # File 'lib/inspec/utils/filter.rb', line 27 def @original_exception. end  | 
  
#resource_failed? ⇒ Boolean
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.
      23 24 25  | 
    
      # File 'lib/inspec/utils/filter.rb', line 23 def resource_failed? @original_exception.is_a?(Inspec::Exceptions::ResourceFailed) end  | 
  
#resource_skipped? ⇒ Boolean
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.
      16 17 18  | 
    
      # 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) ⇒ Boolean
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
      39 40 41  | 
    
      # File 'lib/inspec/utils/filter.rb', line 39 def respond_to?(_method, include_all = false) true end  | 
  
#to_ary ⇒ Object
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.
      50 51 52  | 
    
      # File 'lib/inspec/utils/filter.rb', line 50 def to_ary [ to_s ] end  | 
  
#to_s ⇒ Object Also known as: inspect
      43 44 45  | 
    
      # File 'lib/inspec/utils/filter.rb', line 43 def to_s "#{@original_resource} (#{@original_exception.})" end  |