Exception: Minitest::Assertion

Inherits:
Exception
  • Object
show all
Defined in:
lib/minitest.rb

Overview

Represents run failures.

Direct Known Subclasses

Skip, UnexpectedError

Constant Summary collapse

RE =

:nodoc:

/in .(?:assert|refute|flunk|pass|fail|raise|must|wont)/

Instance Method Summary collapse

Instance Method Details

#errorObject

:nodoc:



967
968
969
# File 'lib/minitest.rb', line 967

def error # :nodoc:
  self
end

#locationObject

Where was this run before an assertion was raised?



974
975
976
977
978
979
980
# File 'lib/minitest.rb', line 974

def location
  bt  = Minitest.filter_backtrace self.backtrace
  idx = bt.rindex { |s| s.match? RE } || -1 # fall back to first item
  loc = bt[idx+1] || bt.last || "unknown:-1"

  loc.sub(/:in .*$/, "")
end

#result_codeObject

:nodoc:



982
983
984
# File 'lib/minitest.rb', line 982

def result_code # :nodoc:
  result_label[0, 1]
end

#result_labelObject

:nodoc:



986
987
988
# File 'lib/minitest.rb', line 986

def result_label # :nodoc:
  "Failure"
end