<commit_before>require_relative '../spec_helper'

module Kamerling describe '.UUIDObject' do
  describe '.new' do
    it 'creates a class with an UUID property defaulting to a random UUID' do
      AttrLess = Kamerling.UUIDObject
      AttrLess.new.uuid.must_match(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
      AttrLess.new.uuid.wont_equal AttrLess.new.uuid
    end

    it 'allows setting custom properties and raises when they lack defaults' do
      FooFul = Kamerling.UUIDObject :foo
      FooFul.new(foo: 'bar').foo.must_equal 'bar'
      -> { FooFul.new }.must_raise RuntimeError
    end

    it 'allows setting properties’ default procs' do
      ProcFul = Kamerling.UUIDObject rand: -> { rand }
      ProcFul.new.rand.wont_equal ProcFul.new.rand
    end

    it 'allows setting properties’ default values' do
      ValFul = Kamerling.UUIDObject bar: :baz
      ValFul.new.bar.must_equal :baz
    end
  end

  describe '#==' do
    it 'reports UUID-based euqality' do
      Actor = Kamerling.UUIDObject :name
      Actor.new(name: :laurel).wont_equal Actor.new(name: :laurel)
      uuid = UUID.new
      Actor.new(name: :laurel, uuid: uuid)
        .must_equal Actor.new(name: :hardy, uuid: uuid)
    end
  end
end end<commit_msg>spec UUIDObject#to_h<commit_after>require_relative '../spec_helper'

module Kamerling describe '.UUIDObject' do
  describe '.new' do
    it 'creates a class with an UUID property defaulting to a random UUID' do
      AttrLess = Kamerling.UUIDObject
      AttrLess.new.uuid.must_match(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
      AttrLess.new.uuid.wont_equal AttrLess.new.uuid
    end

    it 'allows setting custom properties and raises when they lack defaults' do
      FooFul = Kamerling.UUIDObject :foo
      FooFul.new(foo: 'bar').foo.must_equal 'bar'
      -> { FooFul.new }.must_raise RuntimeError
    end

    it 'allows setting properties’ default procs' do
      ProcFul = Kamerling.UUIDObject rand: -> { rand }
      ProcFul.new.rand.wont_equal ProcFul.new.rand
    end

    it 'allows setting properties’ default values' do
      ValFul = Kamerling.UUIDObject bar: :baz
      ValFul.new.bar.must_equal :baz
    end
  end

  describe '#==' do
    it 'reports UUID-based euqality' do
      Actor = Kamerling.UUIDObject :name
      Actor.new(name: :laurel).wont_equal Actor.new(name: :laurel)
      uuid = UUID.new
      Actor.new(name: :laurel, uuid: uuid)
        .must_equal Actor.new(name: :hardy, uuid: uuid)
    end
  end

  describe '#to_h' do
    it 'serialises the object to a Hash' do
      Hashable = Kamerling.UUIDObject :param
      Hashable.new(param: :val).to_h.must_equal({ param: :val, uuid: anything })
    end
  end
end end
{'fraction_non_alphanumeric': 0.11102831594634874, 'fraction_numerical': 0.004470938897168405, 'mean_word_length': 2.8633093525179856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6419429', 'n_tokens_mistral': 965, 'n_tokens_neox': 927, 'n_words': 242}