Class: Test::Unit::Failure
- Inherits:
-
Object
- Object
- Test::Unit::Failure
- Defined in:
- 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'
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#test_name ⇒ Object
readonly
Returns the value of attribute test_name.
Instance Method Summary collapse
-
#initialize(test_name, location, message) ⇒ Failure
constructor
Creates a new Failure with the given location and message.
-
#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) ⇒ Failure
Creates a new Failure with the given location and message.
19 20 21 22 23 |
# File 'lib/test/unit/failure.rb', line 19 def initialize(test_name, location, ) @test_name = test_name @location = location @message = end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
13 14 15 |
# File 'lib/test/unit/failure.rb', line 13 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
13 14 15 |
# File 'lib/test/unit/failure.rb', line 13 def @message end |
#test_name ⇒ Object (readonly)
Returns the value of attribute test_name.
13 14 15 |
# File 'lib/test/unit/failure.rb', line 13 def test_name @test_name end |
Instance Method Details
#long_display ⇒ Object
Returns a verbose version of the error description.
36 37 38 39 40 41 42 43 |
# File 'lib/test/unit/failure.rb', line 36 def long_display location_display = if(location.size == 1) location[0].sub(/\A(.+:\d+).*/, ' [\\1]') else "\n [#{location.join("\n ")}]" end "Failure:\n#@test_name#{location_display}:\n#@message" end |
#short_display ⇒ Object
Returns a brief version of the error description.
31 32 33 |
# File 'lib/test/unit/failure.rb', line 31 def short_display "#@test_name: #{@message.split("\n")[0]}" end |
#single_character_display ⇒ Object
Returns a single character representation of a failure.
26 27 28 |
# File 'lib/test/unit/failure.rb', line 26 def single_character_display SINGLE_CHARACTER end |
#to_s ⇒ Object
Overridden to return long_display.
46 47 48 |
# File 'lib/test/unit/failure.rb', line 46 def to_s long_display end |