<commit_before>require 'test_helper'
require 'json/patch'

describe "IETF JSON Patch Test" do

  TESTDIR = File.dirname File.expand_path __FILE__
  spec_json    = File.read File.join TESTDIR, 'json-patch-tests', 'spec_tests.json'
  specs = JSON.load spec_json

  describe "Test JSON File" do
    specs.each_with_index do |spec, index|
      next unless spec['doc']


      comment = spec['comment']
      unless spec['disabled']

        describe "A JSON String " do
          it "#{comment || spec['error'] || index}" do

            target_doc     = JSON.dump(spec['doc']) if spec['doc']
            operations_doc = JSON.dump(spec['patch']) if spec['patch']
            expected_doc   = JSON.dump(spec['expected']) if spec['expected']

            if spec['error']
              assert_raises(ex(spec['error'])) do
                JSON.patch(target_doc, operations_doc)
              end
            else
              result_doc = JSON.patch(target_doc, operations_doc)
              assert_equal JSON.parse(expected_doc || target_doc), JSON.parse(result_doc)<commit_msg>Run correct test<commit_after>require 'test_helper'
require 'json/patch'

describe "IETF JSON Patch Test" do

  TESTDIR = File.dirname File.expand_path __FILE__
  spec_json    = File.read File.join TESTDIR, 'json-patch-tests', 'tests.json'
  specs = JSON.load spec_json

  describe "Test JSON File" do
    specs.each_with_index do |spec, index|
      next unless spec['doc']


      comment = spec['comment']
      unless spec['disabled']

        describe "A JSON String " do
          it "#{comment || spec['error'] || index}" do

            target_doc     = JSON.dump(spec['doc']) if spec['doc']
            operations_doc = JSON.dump(spec['patch']) if spec['patch']
            expected_doc   = JSON.dump(spec['expected']) if spec['expected']

            if spec['error']
              assert_raises(ex(spec['error'])) do
                JSON.patch(target_doc, operations_doc)
              end
            else
              result_doc = JSON.patch(target_doc, operations_doc)
              assert_equal JSON.parse(expected_doc || target_doc), JSON.parse(result_doc)
{'fraction_non_alphanumeric': 0.11824953445065177, 'fraction_numerical': 0.0, 'mean_word_length': 2.5520661157024795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '720206', 'n_tokens_mistral': 631, 'n_tokens_neox': 609, 'n_words': 153}