diff --git a/lib/pact/shared/active_support_support.rb b/lib/pact/shared/active_support_support.rb index 2e4826b..40167d0 100644 --- a/lib/pact/shared/active_support_support.rb +++ b/lib/pact/shared/active_support_support.rb @@ -42,10 +42,11 @@ def fix_regexp regexp # Oh ActiveSupport, why.... def fix_json_formatting json if json =~ /\{".*?":"/ - JSON.pretty_generate(JSON.parse(json, create_additions: false)) + json = JSON.pretty_generate(JSON.parse(json, create_additions: false)) else json end + fix_empty_hash_and_array json end def remove_unicode json @@ -61,5 +62,13 @@ def warn_about_regexp(thing) end end end + + private + + def fix_empty_hash_and_array json + json = json.gsub(/({\s*})/, "{\n }") + json.gsub(/\[\s*\]/, "[\n ]") + json + end end end