Class: Assert::Assertions::CheckException

Inherits:
Object
  • Object
show all
Defined in:
lib/assert/assertions.rb

Overview

exception raised utility classes

Direct Known Subclasses

NoRaisedException, RaisedException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exceptions, &block) ⇒ CheckException

Returns a new instance of CheckException.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/assert/assertions.rb', line 352

def initialize(exceptions, &block)
  @exceptions = exceptions
  # rubocop:disable Lint/SuppressedException
  # rubocop:disable Lint/RescueException
  # rubocop:disable Naming/RescuedExceptionsVariableName
  begin
    block.call
  rescue Exception => @exception
  end
  # rubocop:enable Lint/SuppressedException
  # rubocop:enable Lint/RescueException
  # rubocop:enable Naming/RescuedExceptionsVariableName
  @msg = "#{exceptions_sentence(@exceptions)} #{exception_details}"
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



350
351
352
# File 'lib/assert/assertions.rb', line 350

def exception
  @exception
end

#msgObject (readonly)

Returns the value of attribute msg.



350
351
352
# File 'lib/assert/assertions.rb', line 350

def msg
  @msg
end

Instance Method Details

#raised?Boolean

Returns:

  • (Boolean)


367
368
369
# File 'lib/assert/assertions.rb', line 367

def raised?
  !@exception.nil? && is_one_of?(@exception, @exceptions)
end