Class: Test::Unit::Failure
- Inherits:
-
Object
- Object
- Test::Unit::Failure
- Defined in:
- lib/test/unit/failure.rb,
lib/test/unit/failure.rb
Overview
Encapsulates a test failure. Created by Test::Unit::TestCase when an assertion fails.
Constant Summary collapse
- SINGLE_CHARACTER =
'F'
- LABEL =
"Failure"
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#inspected_actual ⇒ Object
readonly
Returns the value of attribute inspected_actual.
-
#inspected_expected ⇒ Object
readonly
Returns the value of attribute inspected_expected.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#source_location ⇒ Object
readonly
Returns the value of attribute source_location.
-
#test_name ⇒ Object
readonly
Returns the value of attribute test_name.
-
#user_message ⇒ Object
readonly
Returns the value of attribute user_message.
Instance Method Summary collapse
-
#critical? ⇒ Boolean
-
#diff ⇒ Object
-
#initialize(test_name, location, message, options = {}) ⇒ Failure
constructor
Creates a new Failure with the given location and message.
-
#label ⇒ Object
-
#long_display ⇒ Object
Returns a verbose version of the error description.
-
#short_display ⇒ Object
Returns a brief version of the error description.
-
#single_character_display ⇒ Object
Returns a single character representation of a failure.
-
#to_s ⇒ Object
Overridden to return long_display.
Constructor Details
#initialize(test_name, location, message, options = {}) ⇒ Failure
Creates a new Failure with the given location and message.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/test/unit/failure.rb', line 17 def initialize(test_name, location, , ={}) @test_name = test_name @location = location @message = @method_name = [:method_name] @source_location = [:source_location] @expected = [:expected] @actual = [:actual] @inspected_expected = [:inspected_expected] @inspected_actual = [:inspected_actual] @user_message = [:user_message] end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual
9 10 11 |
# File 'lib/test/unit/failure.rb', line 9 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected
9 10 11 |
# File 'lib/test/unit/failure.rb', line 9 def expected @expected end |
#inspected_actual ⇒ Object (readonly)
Returns the value of attribute inspected_actual
10 11 12 |
# File 'lib/test/unit/failure.rb', line 10 def inspected_actual @inspected_actual end |
#inspected_expected ⇒ Object (readonly)
Returns the value of attribute inspected_expected
10 11 12 |
# File 'lib/test/unit/failure.rb', line 10 def inspected_expected @inspected_expected end |
#location ⇒ Object (readonly)
Returns the value of attribute location
7 8 9 |
# File 'lib/test/unit/failure.rb', line 7 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message
7 8 9 |
# File 'lib/test/unit/failure.rb', line 7 def @message end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name
8 9 10 |
# File 'lib/test/unit/failure.rb', line 8 def method_name @method_name end |
#source_location ⇒ Object (readonly)
Returns the value of attribute source_location
8 9 10 |
# File 'lib/test/unit/failure.rb', line 8 def source_location @source_location end |
#test_name ⇒ Object (readonly)
Returns the value of attribute test_name
7 8 9 |
# File 'lib/test/unit/failure.rb', line 7 def test_name @test_name end |
#user_message ⇒ Object (readonly)
Returns the value of attribute user_message
9 10 11 |
# File 'lib/test/unit/failure.rb', line 9 def @user_message end |
Instance Method Details
#critical? ⇒ Boolean
59 60 61 |
# File 'lib/test/unit/failure.rb', line 59 def critical? true end |
#diff ⇒ Object
63 64 65 |
# File 'lib/test/unit/failure.rb', line 63 def diff @diff ||= compute_diff end |
#label ⇒ Object
35 36 37 |
# File 'lib/test/unit/failure.rb', line 35 def label LABEL end |
#long_display ⇒ Object
Returns a verbose version of the error description.
45 46 47 48 49 50 51 52 |
# File 'lib/test/unit/failure.rb', line 45 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 ⇒ Object
Returns a brief version of the error description.
40 41 42 |
# File 'lib/test/unit/failure.rb', line 40 def short_display "#@test_name: #{@message.split("\n")[0]}" end |
#single_character_display ⇒ Object
Returns a single character representation of a failure.
31 32 33 |
# File 'lib/test/unit/failure.rb', line 31 def single_character_display SINGLE_CHARACTER end |
#to_s ⇒ Object
Overridden to return long_display.
55 56 57 |
# File 'lib/test/unit/failure.rb', line 55 def to_s long_display end |