<commit_before>require 'spec_helper'

require 'serf/util/uuidable'

##
# NOTE: Not really great tests here... I need to mock out
#   the uuid_tool to really get at the meat of the work.
#
describe Serf::Util::Uuidable do

  its(:create_coded_uuid) {
    expect(subject).to_not be_nil
    expect(subject.size).to eq(22)
  }

  describe '#parse_coded_uuid' do

    it 'works' do
      subject.parse_coded_uuid subject.create_coded_uuid
    end

  end

  describe '#coded_uuid_time' do
    let(:coded_uuid) {
      'RIEHuF5-EeKLPQQMzuOZ7g'
    }
    let(:rational_time) {
      Rational(1424166190604169, 1048576)
    }

    it 'returns a valid time object' do
      time = subject.coded_uuid_time coded_uuid
      expect(time.to_r).to eq(rational_time)
    end

  end

  describe '#create_uuids' do

    it 'works with no parent' do
      uuids = subject.create_uuids
      expect(uuids[:uuid]).to_not be_nil
      expect(uuids[:parent_uuid]).to be_nil<commit_msg>FIX: Uuidable spec, diff rubies return diff to_r.<commit_after>require 'spec_helper'

require 'serf/util/uuidable'

##
# NOTE: Not really great tests here... I need to mock out
#   the uuid_tool to really get at the meat of the work.
#
describe Serf::Util::Uuidable do

  its(:create_coded_uuid) {
    expect(subject).to_not be_nil
    expect(subject.size).to eq(22)
  }

  describe '#parse_coded_uuid' do

    it 'works' do
      subject.parse_coded_uuid subject.create_coded_uuid
    end

  end

  describe '#coded_uuid_time' do
    let(:coded_uuid) {
      'RIEHuF5-EeKLPQQMzuOZ7g'
    }
    let(:time_seconds) {
      1358190718
    }
    let(:time_nsec) {
      273324012
    }

    it 'returns a valid time object' do
      time = subject.coded_uuid_time coded_uuid
      # Check that we have a good timestamp in seconds and nanoseconds
      expect(time.to_i).to eq(time_seconds)
      expect(time.tv_nsec).to eq(time_nsec)
    end

  end

  describe '#create_uuids' do

    it 'works with no parent' do
      uuids = subject.create_uuids
      expect(uuids[:uuid]).to_not be_nil
      expect(uuids[:parent_uuid]).to be_nil
{'fraction_non_alphanumeric': 0.09369024856596558, 'fraction_numerical': 0.02390057361376673, 'mean_word_length': 3.087890625, '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': '2991154', 'n_tokens_mistral': 800, 'n_tokens_neox': 728, 'n_words': 182}