FIX: Made turbo_rspec display errors in shared groups correctly

FIX: Made turbo_rspec display errors in shared groups correctly

diff --git a/lib/turbo_tests.rb b/lib/turbo_tests.rb
index acb01a9..8d2c3a0 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 b10f9d8..c83ee32 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
       }

GitHub sha: 6b9784cf

1 Like