<commit_before># frozen_string_literal: true

RSpec.describe LazyLazer do
  let(:model_class) { Class.new { include LazyLazer } }

  describe '.property' do
    it 'returns the created property name' do
      expect(model_class.property(:hello)).to eq(:hello)
    end

    it 'makes the method callable from instances' do
      model_class.property(:hello)
      model = model_class.new(hello: 'world')
      expect(model.hello).to eq('world')
    end

    it 'converts a parameter to a key where the value is true' do
      model_class.property(:hello, :required)
      expect { model_class.new }.to raise_error(LazyLazer::RequiredAttribute, /hello/)
    end
  end

  describe '#initialize' do
    it "sets the model's attributes" do
      model_class.property(:hello)
      model = model_class.new(hello: 'world')
      expect(model.hello).to eq('world')
    end
  end

  describe '#==' do
    context 'when the other object is a different class' do
      it 'returns false' do
        model_class.property(:hello, :required)
        one = model_class.new(hello: 1)
        expect(one).not_to eq(10)
      end
    end

    context 'when object has no required properties' do
      it 'falls back to super (i.e. memory addresses)' do
        model_class.property(:hello)
        model_class.property(:world)
        one = model_class.new(hello: 1, world: 1)
        two = model_class.new(hello: 1, world: 1)
        expect(one).not_to eq(two)
      end
    end

    context 'when the other object has a non-equal required property' do<commit_msg>Add tests for the hotfix.<commit_after># frozen_string_literal: true

RSpec.describe LazyLazer do
  let(:model_class) { Class.new { include LazyLazer } }

  describe '.property' do
    it 'returns the created property name' do
      expect(model_class.property(:hello)).to eq(:hello)
    end

    it 'makes the method callable from instances' do
      model_class.property(:hello)
      model = model_class.new(hello: 'world')
      expect(model.hello).to eq('world')
    end

    it 'converts a parameter to a key where the value is true' do
      model_class.property(:hello, :required)
      expect { model_class.new }.to raise_error(LazyLazer::RequiredAttribute, /hello/)
    end
  end

  describe '.inherited' do
    it 'copies the source keys' do
      parent_class = Class.new(model_class)
      parent_class.property(:foo)
      child_class = Class.new(parent_class)
      child = child_class.new(foo: :bar)
      expect(child.foo).to eq(:bar)
    end

    it "doesn't modify the parent store" do
      parent_class = Class.new(model_class)
      parent_class.property(:foo)
      child_class = Class.new(parent_class)
      child_class.property(:bar)
      expect(parent_class.new).not_to respond_to(:bar)
    end

    it 'allows redefining keys and their properties' do
      parent_class = Class.new(model_class)
      parent_class.property(:foo, :required)
      child_class = Class.new(parent_class)
      child_class.property(:foo)
      expect { child_class.new(bar: 1) }.not_to raise_error
    end
  end

  describe '#initialize' do
    it "sets the model's attributes" do
      model_class.property(:hello)
      model = model_class.new(hello: 'world')
      expect(model.hello).to eq('world')
    end
  end

  describe '#==' do
    context 'when the other object is a different class' do
      it 'returns false' do
        model_class.property(:hello, :required)
        one = model_class.new(hello: 1)
        expect(one).not_to eq(10)
      end
    end

    context 'when object has no required properties' do
      it 'falls back to super (i.e. memory addresses)' do
        model_class.property(:hello)
        model_class.property(:world)
        one = model_class.new(hello: 1, world: 1)
        two = model_class.new(hello: 1, world: 1)
        expect(one).not_to eq(two)
      end
    end

    context 'when the other object has a non-equal required property' do
{'fraction_non_alphanumeric': 0.10111788617886179, 'fraction_numerical': 0.0038109756097560975, 'mean_word_length': 2.898019801980198, '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': '4191890', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1188, 'n_words': 353}