<commit_before>require 'spec_helper'
require 'action_controller'

module SearchObject
  describe Helper do
    describe '.stringify_keys' do
      it 'converts hash keys to strings' do
        hash = Helper.stringify_keys a: 1, b: nil, c: false
        expect(hash).to eq 'a' => 1, 'b' => nil, 'c' => false
      end

      it 'converts ActionController::Parameters to hash' do
        params = ::ActionController::Parameters.new a: 1, b: nil, c: false
        hash = Helper.stringify_keys params
        expect(hash).to eq 'a' => 1, 'b' => nil, 'c' => false
      end
    end

    describe '.slice_keys' do
      it 'selects only given keys' do
        hash = Helper.slice_keys({ a: 1, b: 2, c: 3 }, [:a, :b])
        expect(hash).to eq a: 1, b: 2
      end

      it 'ignores not existing keys' do
        hash = Helper.slice_keys({}, [:a, :b])
        expect(hash).to eq({})
      end
    end

    describe 'camelize' do
      it "transforms :paging to 'Paging'" do
        expect(Helper.camelize(:paging)).to eq 'Paging'
      end
    end

    describe 'deep_copy' do
      it 'returns a deep copy on the given object' do
        original = {
          array: [1, 2, 3],
          hash: { key: 'value' },
          boolean: true,
          number: 1,
          null: nil
        }

        deep_copy = Helper.deep_copy(original)

        original[:array][0] = 42
        original[:hash][:key] = 'other value'

        expect(deep_copy).to eq(<commit_msg>Use `described_class` instead of full object name<commit_after>require 'spec_helper'
require 'action_controller'

module SearchObject
  describe Helper do
    describe '.stringify_keys' do
      it 'converts hash keys to strings' do
        hash = described_class.stringify_keys a: 1, b: nil, c: false
        expect(hash).to eq 'a' => 1, 'b' => nil, 'c' => false
      end

      it 'converts ActionController::Parameters to hash' do
        params = ::ActionController::Parameters.new a: 1, b: nil, c: false
        hash = described_class.stringify_keys params
        expect(hash).to eq 'a' => 1, 'b' => nil, 'c' => false
      end
    end

    describe '.slice_keys' do
      it 'selects only given keys' do
        hash = described_class.slice_keys({ a: 1, b: 2, c: 3 }, [:a, :b])
        expect(hash).to eq a: 1, b: 2
      end

      it 'ignores not existing keys' do
        hash = described_class.slice_keys({}, [:a, :b])
        expect(hash).to eq({})
      end
    end

    describe 'camelize' do
      it "transforms :paging to 'Paging'" do
        expect(described_class.camelize(:paging)).to eq 'Paging'
      end
    end
      end
    end

    describe 'deep_copy' do
      it 'returns a deep copy on the given object' do
        original = {
          array: [1, 2, 3],
          hash: { key: 'value' },
          boolean: true,
          number: 1,
          null: nil
        }

        deep_copy = described_class.deep_copy(original)

        original[:array][0] = 42
        original[:hash][:key] = 'other value'

        expect(deep_copy).to eq(
{'fraction_non_alphanumeric': 0.12169312169312169, 'fraction_numerical': 0.010582010582010581, 'mean_word_length': 2.154327424400417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4759223', 'n_tokens_mistral': 996, 'n_tokens_neox': 948, 'n_words': 313}