Class: Tryouts::FailureCollector::FailureEntry
- Inherits:
-
Data
- Object
- Data
- Tryouts::FailureCollector::FailureEntry
- Defined in:
- lib/tryouts/failure_collector.rb
Overview
Data structure for a single failure entry
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#result_packet ⇒ Object
readonly
Returns the value of attribute result_packet.
-
#test_case ⇒ Object
readonly
Returns the value of attribute test_case.
Instance Method Summary collapse
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path
12 13 14 |
# File 'lib/tryouts/failure_collector.rb', line 12 def file_path @file_path end |
#result_packet ⇒ Object (readonly)
Returns the value of attribute result_packet
12 13 14 |
# File 'lib/tryouts/failure_collector.rb', line 12 def result_packet @result_packet end |
#test_case ⇒ Object (readonly)
Returns the value of attribute test_case
12 13 14 |
# File 'lib/tryouts/failure_collector.rb', line 12 def test_case @test_case end |
Instance Method Details
#description ⇒ Object
18 19 20 21 |
# File 'lib/tryouts/failure_collector.rb', line 18 def description desc = test_case.description.to_s.strip desc.empty? ? 'unnamed test' : desc end |
#failure_reason ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tryouts/failure_collector.rb', line 23 def failure_reason case result_packet.status when :failed if result_packet.actual_results.any? && result_packet.expected_results.any? "expected #{result_packet.first_expected.inspect}, got #{result_packet.first_actual.inspect}" else 'test failed' end when :error error_msg = result_packet.error&. || 'unknown error' "#{result_packet.error&.class&.name || 'Error'}: #{error_msg}" else 'test did not pass' end end |
#line_number ⇒ Object
13 14 15 16 |
# File 'lib/tryouts/failure_collector.rb', line 13 def line_number # Use first expectation line for consistency with main error display test_case.first_expectation_line || test_case.line_range&.first || 0 end |
#source_context ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/tryouts/failure_collector.rb', line 39 def source_context return [] unless test_case.source_lines # Show the test code (excluding setup/teardown) test_case.source_lines.reject do |line| line.strip.empty? || line.strip.start_with?('#') end.first(3) # Limit to first 3 relevant lines end |