From 8a0be71b3c2af174bca1043565322bbc640ab9ed Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Thu, 27 Jun 2019 11:43:12 +0100 Subject: [PATCH] FIX: FakeExceptions should have the original class name --- lib/turbo_tests.rb | 10 +++++++++- lib/turbo_tests/json_rows_formatter.rb | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/turbo_tests.rb b/lib/turbo_tests.rb index 8e3b5cc9e7e..337e265763d 100644 --- a/lib/turbo_tests.rb +++ b/lib/turbo_tests.rb @@ -19,7 +19,15 @@ module TurboTests def self.from_obj(obj) if obj obj = obj.symbolize_keys - new( + + klass = + Class.new(FakeException) do + define_singleton_method(:name) do + obj[:class_name] + end + end + + klass.new( obj[:backtrace], obj[:message], FakeException.from_obj(obj[:cause]) diff --git a/lib/turbo_tests/json_rows_formatter.rb b/lib/turbo_tests/json_rows_formatter.rb index 6a9ca69f924..b10f9d8657d 100644 --- a/lib/turbo_tests/json_rows_formatter.rb +++ b/lib/turbo_tests/json_rows_formatter.rb @@ -21,6 +21,7 @@ module TurboTests def exception_to_json(exception) if exception { + class_name: exception.class.name.to_s, backtrace: exception.backtrace, message: exception.message, cause: exception_to_json(exception.cause)