Sha256: 0ec26b0a4a6d16bb61793f92d5df601589466bae2920ab7bf29e549e6115bac4

Contents?: true

Size: 819 Bytes

Versions: 13

Compression:

Stored size: 819 Bytes

Contents

require 'spec_helper'

describe ::Trax::Model::UUID do
  let(:product) { ::Product.create(:name => "iMac") }
  subject{ product.uuid }

  context "dsl register methods" do
    before do
      ::Trax::Model::UUID.register do
        prefix "9a", ::Person
      end
    end

    it { described_class.prefix_map.should have_key("9a") }
    it { described_class.klass_prefix_map.should have_key(Person) }
  end

  its(:record_type) { should eq ::Product }
  its(:record) { should eq product }

  describe ".generate" do
    context "with prefix" do
      let(:prefixed_uuid) { described_class.generate("1a") }
      it { prefixed_uuid[0..1].should eq "1a" }
    end

    context "without prefix" do
      let(:unprefixed_uuid) { described_class.generate }
      it { unprefixed_uuid.length.should eq 36 }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trax_model-0.1.0 spec/trax/model/uuid_spec.rb
trax_model-0.0.99 spec/trax/model/uuid_spec.rb
trax_model-0.0.98 spec/trax/model/uuid_spec.rb
trax_model-0.0.97 spec/trax/model/uuid_spec.rb
trax_model-0.0.96 spec/trax/model/uuid_spec.rb
trax_model-0.0.95 spec/trax/model/uuid_spec.rb
trax_model-0.0.93 spec/trax/model/uuid_spec.rb
trax_model-0.0.92 spec/trax/model/uuid_spec.rb
trax_model-0.0.91 spec/trax/model/uuid_spec.rb
trax_model-0.0.9 spec/trax/model/uuid_spec.rb
trax_model-0.0.8 spec/trax/model/uuid_spec.rb
trax_model-0.0.7 spec/trax/model/uuid_spec.rb
trax_model-0.0.6 spec/trax/model/uuid_spec.rb