Class: Loupe::Failure
- Inherits:
-
Object
- Object
- Loupe::Failure
- Defined in:
- lib/loupe/failure.rb
Overview
Failure
This class represents a single test failure. It corresponds to one method that was executed and had failed expectations.
Instance Attribute Summary collapse
- #file_name ⇒ String readonly
- #klass ⇒ Class readonly
- #line_number ⇒ Integer readonly
- #message ⇒ String readonly
- #test_name ⇒ String readonly
Instance Method Summary collapse
- #initialize(test, message) ⇒ Loupe::Failure constructor
- #location_and_message ⇒ Array<String>
- #to_s ⇒ String
Constructor Details
#initialize(test, message) ⇒ Loupe::Failure
27 28 29 30 31 32 33 34 |
# File 'lib/loupe/failure.rb', line 27 def initialize(test, ) @file_name = test.file @test_name = test.name @line_number = test.line_number @klass = test.class @color = test.color @message = end |
Instance Attribute Details
#file_name ⇒ String (readonly)
10 11 12 |
# File 'lib/loupe/failure.rb', line 10 def file_name @file_name end |
#klass ⇒ Class (readonly)
22 23 24 |
# File 'lib/loupe/failure.rb', line 22 def klass @klass end |
#line_number ⇒ Integer (readonly)
19 20 21 |
# File 'lib/loupe/failure.rb', line 19 def line_number @line_number end |
#message ⇒ String (readonly)
16 17 18 |
# File 'lib/loupe/failure.rb', line 16 def @message end |
#test_name ⇒ String (readonly)
13 14 15 |
# File 'lib/loupe/failure.rb', line 13 def test_name @test_name end |
Instance Method Details
#location_and_message ⇒ Array<String>
42 43 44 45 46 47 |
# File 'lib/loupe/failure.rb', line 42 def [ "#{file_name}:#{line_number} at #{@color.p(test_name, :yellow)}", ] end |
#to_s ⇒ String
37 38 39 |
# File 'lib/loupe/failure.rb', line 37 def to_s "#{file_name}:#{line_number} at #{@color.p(test_name, :yellow)}. #{}" end |