Class: Ace::TestRunner::Models::TestFailure
- Inherits:
-
Object
- Object
- Ace::TestRunner::Models::TestFailure
- Defined in:
- lib/ace/test_runner/models/test_failure.rb
Overview
Represents a single test failure or error
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#code_context ⇒ Object
Returns the value of attribute code_context.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#fix_suggestion ⇒ Object
Returns the value of attribute fix_suggestion.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#message ⇒ Object
Returns the value of attribute message.
-
#stderr_warnings ⇒ Object
Returns the value of attribute stderr_warnings.
-
#test_class ⇒ Object
Returns the value of attribute test_class.
-
#test_name ⇒ Object
Returns the value of attribute test_name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #detailed_description ⇒ Object
- #error? ⇒ Boolean
- #failure? ⇒ Boolean
- #full_test_name ⇒ Object
-
#initialize(attributes = {}) ⇒ TestFailure
constructor
A new instance of TestFailure.
- #location ⇒ Object
- #short_location ⇒ Object
- #summary_line ⇒ Object
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ TestFailure
Returns a new instance of TestFailure.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 12 def initialize(attributes = {}) @type = attributes[:type] || :failure # :failure or :error @test_name = attributes[:test_name] @test_class = attributes[:test_class] @message = attributes[:message] @file_path = attributes[:file_path] @line_number = attributes[:line_number] @backtrace = attributes[:backtrace] || [] @fix_suggestion = attributes[:fix_suggestion] @code_context = attributes[:code_context] @stderr_warnings = attributes[:stderr_warnings] end |
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def backtrace @backtrace end |
#code_context ⇒ Object
Returns the value of attribute code_context.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def code_context @code_context end |
#file_path ⇒ Object
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def file_path @file_path end |
#fix_suggestion ⇒ Object
Returns the value of attribute fix_suggestion.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def fix_suggestion @fix_suggestion end |
#line_number ⇒ Object
Returns the value of attribute line_number.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def line_number @line_number end |
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def @message end |
#stderr_warnings ⇒ Object
Returns the value of attribute stderr_warnings.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def stderr_warnings @stderr_warnings end |
#test_class ⇒ Object
Returns the value of attribute test_class.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def test_class @test_class end |
#test_name ⇒ Object
Returns the value of attribute test_name.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def test_name @test_name end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 8 def type @type end |
Instance Method Details
#detailed_description ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 58 def detailed_description lines = [] lines << "#{type_icon} #{type.to_s.capitalize}: #{full_test_name}" lines << " Location: #{location}" if location lines << " Message: #{}" if lines << " Fix: #{fix_suggestion}" if fix_suggestion lines.join("\n") end |
#error? ⇒ Boolean
46 47 48 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 46 def error? type == :error end |
#failure? ⇒ Boolean
50 51 52 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 50 def failure? type == :failure end |
#full_test_name ⇒ Object
42 43 44 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 42 def full_test_name test_class ? "#{test_class}##{test_name}" : test_name.to_s end |
#location ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 25 def location return nil unless file_path if line_number "#{file_path}:#{line_number}" else file_path end end |
#short_location ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 35 def short_location return nil unless file_path base_name = File.basename(file_path) line_number ? "#{base_name}:#{line_number}" : base_name end |
#summary_line ⇒ Object
54 55 56 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 54 def summary_line "#{type_icon} #{full_test_name} - #{short_location}" end |
#to_h ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 67 def to_h { type: type, test_name: test_name, test_class: test_class, message: , location: location, file_path: file_path, line_number: line_number, backtrace: backtrace, fix_suggestion: fix_suggestion, code_context: code_context, stderr_warnings: stderr_warnings } end |
#to_json(*args) ⇒ Object
83 84 85 |
# File 'lib/ace/test_runner/models/test_failure.rb', line 83 def to_json(*args) to_h.to_json(*args) end |