Skip to content

Commit f54a97c

Browse files
authored
Merge pull request #112 from pact-foundation/fix/diff_change_ruby_3_json_2_8_regression_pact_ruby
fix: add blank lines to empty hashs - json 2.8.x regression for pact-…
2 parents 860b6de + f8cb384 commit f54a97c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/pact/shared/active_support_support.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ def fix_regexp regexp
4242
# Oh ActiveSupport, why....
4343
def fix_json_formatting json
4444
if json =~ /\{".*?":"/
45-
JSON.pretty_generate(JSON.parse(json, create_additions: false))
45+
json = JSON.pretty_generate(JSON.parse(json, create_additions: false))
4646
else
4747
json
4848
end
49+
fix_empty_hash_and_array json
4950
end
5051

5152
def remove_unicode json
@@ -61,5 +62,13 @@ def warn_about_regexp(thing)
6162
end
6263
end
6364
end
65+
66+
private
67+
68+
def fix_empty_hash_and_array json
69+
json = json.gsub(/({\s*})/, "{\n }")
70+
json.gsub(/\[\s*\]/, "[\n ]")
71+
json
72+
end
6473
end
6574
end

0 commit comments

Comments
 (0)