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.


271
272
273
274
275
# File 'lib/assert/assertions.rb', line 271

def initialize(exceptions, &block)
  @exceptions = exceptions
  begin; block.call; rescue Exception => @exception; end
  @msg = "#{exceptions_sentence(@exceptions)} #{exception_details}"
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception


269
270
271
# File 'lib/assert/assertions.rb', line 269

def exception
  @exception
end

#msgObject (readonly)

Returns the value of attribute msg


269
270
271
# File 'lib/assert/assertions.rb', line 269

def msg
  @msg
end

Instance Method Details

#raised?Boolean

Returns:

  • (Boolean)

277
278
279
# File 'lib/assert/assertions.rb', line 277

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