Exception: Minitest::UnexpectedError

Inherits:
Assertion show all
Includes:
Compress
Defined in:
lib/minitest.rb

Overview

Assertion wrapping an unexpected error that was raised during a run.

Constant Summary collapse

BASE_RE =

:nodoc:

%r%#{Dir.pwd}/%

Constants inherited from Assertion

Assertion::RE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Compress

#compress

Methods inherited from Assertion

#location, #result_code

Constructor Details

#initialize(error) ⇒ UnexpectedError

:nodoc:



1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
# File 'lib/minitest.rb', line 1007

def initialize error # :nodoc:
  super "Unexpected exception"

  if SystemStackError === error then
    bt = error.backtrace
    new_bt = compress bt
    error = error.exception "#{bt.size} -> #{new_bt.size}"
    error.set_backtrace new_bt
  end

  self.error = error
end

Instance Attribute Details

#errorObject

TODO: figure out how to use ‘cause` instead



1005
1006
1007
# File 'lib/minitest.rb', line 1005

def error
  @error
end

Instance Method Details

#backtraceObject

:nodoc:



1020
1021
1022
# File 'lib/minitest.rb', line 1020

def backtrace # :nodoc:
  self.error.backtrace
end

#messageObject

:nodoc:



1026
1027
1028
1029
1030
# File 'lib/minitest.rb', line 1026

def message # :nodoc:
  bt = Minitest.filter_backtrace(self.backtrace).join("\n    ")
    .gsub(BASE_RE, "")
  "#{self.error.class}: #{self.error.message}\n    #{bt}"
end

#result_labelObject

:nodoc:



1032
1033
1034
# File 'lib/minitest.rb', line 1032

def result_label # :nodoc:
  "Error"
end