<commit_before>require 'spec_helper'

describe Twin do

  describe :consolidate do

    describe "with an empty collection" do
      let(:collection) { [] }
      it { expect(Twin.consolidate(collection)).to eq(nil) }
    end

    describe "with a collection of all same elements" do
      let(:collection) { [{ a: 'a' }, { a: 'a' }, { a: 'a' }] }
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a' }.with_indifferent_access) }
    end

    describe "with a collection of all different elements" do
      let(:collection) { [{ a: 'a' }, { b: 'b' }, { c: 'c' }] }
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: 'b', c: 'c' }.with_indifferent_access) }
    end

    describe "with a collection of same and different elements" do
      let(:collection) { [{ a: 'a', b: 'b' }, { a: 'a', b: 'b' }, { a: 'a', b: 'b', c: 'c' }] }
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: 'b', c: 'c' }.with_indifferent_access) }
    end

    describe "with nested hashes" do
      let(:collection) do
        [{ a: 'a',
            b: {
              x: 'x',
              y: 'y'
            }
          },
          { a: 'a',
            b: {
              x: 'x',
              y: 'y'
            }
          }]
      end
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: { x: 'x', y: 'y' }}.with_indifferent_access) }<commit_msg>Add a spec for nested arrays<commit_after>require 'spec_helper'

describe Twin do

  describe :consolidate do

    describe "with an empty collection" do
      let(:collection) { [] }
      it { expect(Twin.consolidate(collection)).to eq(nil) }
    end

    describe "with a collection of all same elements" do
      let(:collection) { [{ a: 'a' }, { a: 'a' }, { a: 'a' }] }
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a' }.with_indifferent_access) }
    end

    describe "with a collection of all different elements" do
      let(:collection) { [{ a: 'a' }, { b: 'b' }, { c: 'c' }] }
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: 'b', c: 'c' }.with_indifferent_access) }
    end

    describe "with a collection of same and different elements" do
      let(:collection) { [{ a: 'a', b: 'b' }, { a: 'a', b: 'b' }, { a: 'a', b: 'b', c: 'c' }] }
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: 'b', c: 'c' }.with_indifferent_access) }
    end

    describe "with nested arrays" do
      let(:collection) do
        [
          {
            a: 'a',
            b: [{ x: 'xx' }]
          },
          {
            a: 'a',
            b: [{ x: 'x' }]
          },
          {
            a: 'aa',
            b: [{ x: 'x' }]
          }
        ]
      end
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: [{ x: 'x' }] }.with_indifferent_access) }
    end

    describe "with nested hashes" do
      let(:collection) do
        [{ a: 'a',
            b: {
              x: 'x',
              y: 'y'
            }
          },
          { a: 'a',
            b: {
              x: 'x',
              y: 'y'
            }
          }]
      end
      it { expect(Twin.consolidate(collection)).to eq({ a: 'a', b: { x: 'x', y: 'y' }}.with_indifferent_access) }
{'fraction_non_alphanumeric': 0.1793275217932752, 'fraction_numerical': 0.0, 'mean_word_length': 1.8308370044052864, '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': '3662966', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1111, 'n_words': 314}