Class: FilterTable::ExceptionCatcher
- Inherits:
-
Object
- Object
- FilterTable::ExceptionCatcher
- Defined in:
- lib/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) ⇒ Boolean
RSpec will check the object returned to see if it responds to a method before calling it.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(original_resource, original_exception) ⇒ ExceptionCatcher
Returns a new instance of ExceptionCatcher.
11 12 13 14 |
# File 'lib/utils/filter.rb', line 11 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
35 36 37 |
# File 'lib/utils/filter.rb', line 35 def method_missing(*) self end |
Instance Method Details
#resource_exception_message ⇒ Object
30 31 32 |
# File 'lib/utils/filter.rb', line 30 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.
26 27 28 |
# File 'lib/utils/filter.rb', line 26 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.
19 20 21 |
# File 'lib/utils/filter.rb', line 19 def resource_skipped? @original_exception.is_a?(Inspec::Exceptions::ResourceSkipped) end |
#respond_to?(_method) ⇒ 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
42 43 44 |
# File 'lib/utils/filter.rb', line 42 def respond_to?(_method) true end |
#to_s ⇒ Object Also known as: inspect
46 47 48 |
# File 'lib/utils/filter.rb', line 46 def to_s @original_resource.to_s end |