From 6b9784cf8a18636bce281a7e4d18e65a0cbc6290 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Thu, 29 Aug 2019 12:40:06 +0100 Subject: [PATCH] FIX: Made turbo_rspec display errors in shared groups correctly --- lib/turbo_tests.rb | 14 +++++++++++++- lib/turbo_tests/json_rows_formatter.rb | 11 ++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/turbo_tests.rb b/lib/turbo_tests.rb index acb01a909cc..8d2c3a0ed8a 100644 --- a/lib/turbo_tests.rb +++ b/lib/turbo_tests.rb @@ -57,11 +57,23 @@ module TurboTests class FakeExample def self.from_obj(obj) obj = obj.symbolize_keys + metadata = + obj[:metadata].symbolize_keys + + metadata[:shared_group_inclusion_backtrace] + .map! { |frame| + frame = frame.symbolize_keys + RSpec::Core::SharedExampleGroupInclusionStackFrame.new( + frame[:shared_group_name], + frame[:inclusion_location] + ) + } + new( FakeExecutionResult.from_obj(obj[:execution_result]), obj[:location], obj[:full_description], - obj[:metadata].symbolize_keys, + metadata, obj[:location_rerun_argument], ) end diff --git a/lib/turbo_tests/json_rows_formatter.rb b/lib/turbo_tests/json_rows_formatter.rb index b10f9d8657d..c83ee32ce72 100644 --- a/lib/turbo_tests/json_rows_formatter.rb +++ b/lib/turbo_tests/json_rows_formatter.rb @@ -39,6 +39,13 @@ module TurboTests } end + def stack_frame_to_json(frame) + { + shared_group_name: frame.shared_group_name, + inclusion_location: frame.inclusion_location + } + end + def example_to_json(example) { execution_result: execution_result_to_json(example.execution_result), @@ -46,7 +53,9 @@ module TurboTests full_description: example.full_description, metadata: { shared_group_inclusion_backtrace: - example.metadata[:shared_group_inclusion_backtrace] + example + .metadata[:shared_group_inclusion_backtrace] + .map(&method(:stack_frame_to_json)) }, location_rerun_argument: example.location_rerun_argument }