Exception: Assertion

Inherits:
Exception show all
Defined in:
lib/rubytest/core_ext/assertion.rb

Instance Method Summary collapse

Methods inherited from Exception

#priority, #set_assertion, #set_priority

Constructor Details

#initialize(message = nil, options = {}) ⇒ Assertion

New assertion (failure).

Parameters:

  • message (String) (defaults to: nil)

    the failure message

  • options (Hash) (defaults to: {})

    options such as :backtrace



8
9
10
11
12
13
# File 'lib/rubytest/core_ext/assertion.rb', line 8

def initialize(message=nil, options={})
  super(message)
  backtrace = options[:backtrace]
  set_backtrace(backtrace) if backtrace
  @assertion = true
end

Instance Method Details

#assertion?Boolean

Technically any object that affirmatively responds to #assertion? can be taken to be an Assertion. This makes it easier for various libraries to work together without having to depend upon a common Assertion base class.

Returns:

  • (Boolean)


19
20
21
# File 'lib/rubytest/core_ext/assertion.rb', line 19

def assertion?
  true # @assertion
end

#to_sString

Parents error message prefixed with “(assertion)”.

Returns:



26
27
28
# File 'lib/rubytest/core_ext/assertion.rb', line 26

def to_s
  '(assertion) ' + super
end