<commit_before>require File.expand_path('../../spec_helper', __FILE__)
include RightApi::Helper

describe RightApi::Helper do

  context "#fix_array_of_hashes" do
    it "fixes all the keys that have the value as array of hashes" do
      res = fix_array_of_hashes(
        'a' => '1',
        'b' => [1, 2, 3],
        'c' => {1 => 2, 3 => 4},
        'd' => [
          {5 => 6, 7 => 8},
          {9 => 10, 11 => 12}
        ]
      )

      res.should == {
        'a' => '1',
        'b' => [1, 2, 3],
        'c' => {1 => 2, 3 => 4},
        'd[]' => [
          {5 => 6, 7 => 8},
          {9 => 10, 11 => 12}
        ]
      }

    end

    it "fixes recursively all the keys that have an array of hashes as value" do
      res = fix_array_of_hashes(
        'a' => {
          'b' => [
            {1 => 2},
            {3 => 4}
          ],
          'c' => {
            'd' => [
              {5 => 6},
              {7 => 8}
            ]
          }
        }
      )

      res.should == {
        'a' => {
          'b[]' => [
            {1 => 2},
            {3 => 4}
          ],
          'c' => {
            'd[]' => [
              {5 => 6},
              {7 => 8}
            ]
          }
        }
      }
    end

  end
end<commit_msg>acu104862 fix broken specs<commit_after>require File.expand_path('../../spec_helper', __FILE__)
include RightApi::Helper

describe RightApi::Helper do

  context "#fix_array_of_hashes" do
    it "fixes all the keys that have the value as array of hashes" do
      res = fix_array_of_hashes(
        'a' => '1',
        'b' => [1, 2, 3],
        'c' => {1 => 2, 3 => 4},
        'd' => [
          {5 => 6, 7 => 8},
          {9 => 10, 11 => 12}
        ]
      )

      res.should == {
        'a' => '1',
        'b' => [1, 2, 3],
        'c' => {1 => 2, 3 => 4},
        'd[]' => [
          {5 => 6, 7 => 8},
          {9 => 10, 11 => 12}
        ]
      }

    end

    it "fixes key that have a top-level array of hashes as value" do
      res = fix_array_of_hashes(
          'a' => [
              {1 => 2},
              {3 => 4}
          ]
      )

      res.should == {
          'a[]' => [
              {1 => 2},
              {3 => 4}
          ]
      }
    end

    it "fixes key that have a nested array of hashes as value" do
      res = fix_array_of_hashes(
          'a' => {
              'b' => [
                  {1 => 2},
                  {3 => 4}
              ]
          }
      )

      res.should == {
          'a' => {
              'b' => {
                  '' => [
                      {1 => 2},
                      {3 => 4}
                  ]
              }
          }
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.1722860318636532, 'fraction_numerical': 0.04223786587625046, 'mean_word_length': 0.9382627422828428, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 74, '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': '3481811', 'n_tokens_mistral': 1005, 'n_tokens_neox': 901, 'n_words': 243}