class Test::Unit::Failure
Encapsulates a test failure. Created by Test::Unit::TestCase when an assertion fails.
Constants
- LABEL
- SINGLE_CHARACTER
Attributes
actual[R]
expected[R]
inspected_actual[R]
inspected_expected[R]
location[R]
message[R]
method_name[R]
source_location[R]
test_name[R]
user_message[R]
Public Class Methods
new(test_name, location, message, options={})
click to toggle source
Creates a new Failure with the given location and message.
# File lib/test/unit/failure.rb, line 23 def initialize(test_name, location, message, options={}) @test_name = test_name @location = location @message = message @method_name = options[:method_name] @source_location = options[:source_location] @expected = options[:expected] @actual = options[:actual] @inspected_expected = options[:inspected_expected] @inspected_actual = options[:inspected_actual] @user_message = options[:user_message] end
Public Instance Methods
critical?()
click to toggle source
# File lib/test/unit/failure.rb, line 65 def critical? true end
diff()
click to toggle source
# File lib/test/unit/failure.rb, line 69 def diff @diff ||= compute_diff end
label()
click to toggle source
# File lib/test/unit/failure.rb, line 41 def label LABEL end
long_display()
click to toggle source
Returns a verbose version of the error description.
# File lib/test/unit/failure.rb, line 51 def long_display if location.size == 1 location_display = location[0].sub(/\A(.+:\d+).*/, ' [\1]') else location_display = "\n [#{location.join("\n ")}]" end "#{label}:\n#@test_name#{location_display}:\n#@message" end
short_display()
click to toggle source
Returns a brief version of the error description.
# File lib/test/unit/failure.rb, line 46 def short_display "#@test_name: #{@message.split("\n")[0]}" end
single_character_display()
click to toggle source
Returns a single character representation of a failure.
# File lib/test/unit/failure.rb, line 37 def single_character_display SINGLE_CHARACTER end
to_s()
click to toggle source
Overridden to return long_display.
# File lib/test/unit/failure.rb, line 61 def to_s long_display end
Private Instance Methods
compute_diff()
click to toggle source
# File lib/test/unit/failure.rb, line 74 def compute_diff Assertions::AssertionMessage.delayed_diff(@expected, @actual).inspect end