From 0bd975382c98764af83d2d5dd5aa28c54dea434f Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Sat, 21 Mar 2020 12:45:49 +1100 Subject: [PATCH] fix: ensure diff is included in the json output --- lib/pact/provider/rspec/json_formatter.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pact/provider/rspec/json_formatter.rb b/lib/pact/provider/rspec/json_formatter.rb index a3d1eeae..e774cfdc 100644 --- a/lib/pact/provider/rspec/json_formatter.rb +++ b/lib/pact/provider/rspec/json_formatter.rb @@ -30,13 +30,15 @@ def stop(notification) output_hash[:examples] = notification.examples.map do |example| format_example(example).tap do |hash| e = example.exception - # No point providing a backtrace for a mismatch, too much noise - if e && ! e.is_a?(::RSpec::Expectations::ExpectationNotMetError) + if e hash[:exception] = { - :class => e.class.name, - :message => e.message, - :backtrace => e.backtrace, + class: e.class.name, + message: e.message, } + # No point providing a backtrace for a mismatch, too much noise + if !e.is_a?(::RSpec::Expectations::ExpectationNotMetError) + hash[:exception][:backtrace] + end end end end