Module: Pact::JRubySupport

Included in:
Matchers::UnixDiffFormatter
Defined in:
lib/pact/shared/jruby_support.rb

Instance Method Summary collapse

Instance Method Details

#fix_blank_lines_in_empty_hashes(json) ⇒ Object

Under jruby, JSON.pretty_generate inserts a blank new line between the opening and closing brackets of an empty hash, like so: {

"empty": {

}

} This screws up the UnixDiffFormatter, so we need to remove the blank lines.



13
14
15
# File 'lib/pact/shared/jruby_support.rb', line 13

def fix_blank_lines_in_empty_hashes json
  json.gsub(/({\n)\n(\s*})/,'\1\2')
end