Sha256: 19e81a5f502e2378d6ffc6de156f17c6883643721b2866e62a306294a69a8040

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

require 'rails_helper'

RSpec.describe Dorsale::SortableUUIDGenerator do
  it "should generate a valid uuid" do
    uuid = described_class.generate
    expect(uuid).to match described_class::REGEX_WITH_DASHES
  end

  it "should still work in 100 years" do
    Timecop.travel "2116-11-17"
    uuid = described_class.generate
    expect(uuid).to match described_class::REGEX_WITH_DASHES
  end

  it "should be incremental" do
    uuids = []
    1_000.times { uuids << described_class.generate }
    Timecop.travel 1.day.from_now
    1_000.times { uuids << described_class.generate }
    Timecop.travel 1.month.from_now
    1_000.times { uuids << described_class.generate }
    Timecop.travel 1.year.from_now
    1_000.times { uuids << described_class.generate }
    Timecop.travel 10.years.from_now
    1_000.times { uuids << described_class.generate }

    expect(uuids).to eq uuids.dup.sort
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dorsale-3.4.0 spec/libs/dorsale/sortable_uuid_generator_spec.rb
dorsale-3.3.0 spec/libs/dorsale/sortable_uuid_generator_spec.rb
dorsale-3.2.0 spec/libs/dorsale/sortable_uuid_generator_spec.rb