Class: ConvenientService::RSpec::PrimitiveHelpers::Classes::IgnoringException

Inherits:
Support::Command
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_helpers/classes/ignoring_exception.rb,
lib/convenient_service/rspec/primitive_helpers/classes/ignoring_exception/exceptions.rb

Defined Under Namespace

Modules: Exceptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(exception, &block) ⇒ IgnoringException

Returns a new instance of IgnoringException.

Parameters:

  • exception (StandardError)
  • block (Proc)


26
27
28
29
# File 'lib/convenient_service/rspec/primitive_helpers/classes/ignoring_exception.rb', line 26

def initialize(exception, &block)
  @exception = exception
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



20
21
22
# File 'lib/convenient_service/rspec/primitive_helpers/classes/ignoring_exception.rb', line 20

def block
  @block
end

#exceptionObject (readonly)

Returns the value of attribute exception.



14
15
16
# File 'lib/convenient_service/rspec/primitive_helpers/classes/ignoring_exception.rb', line 14

def exception
  @exception
end

Instance Method Details

#callConvenientService::Support::UniqueValue

Note:

Rescue ‘StandardError`, NOT `Exception`.



40
41
42
43
44
45
46
# File 'lib/convenient_service/rspec/primitive_helpers/classes/ignoring_exception.rb', line 40

def call
  block.call
rescue exception
  Support::UNDEFINED
else
  ::ConvenientService.raise Exceptions::IgnoredExceptionIsNotRaised.new(exception: exception)
end