Sha256: 0112490099975e8f7805f8646f26367978f63f57e120aa2b176774d6c8826c41

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

require 'helper'

describe Toy::Identity::UUIDKeyFactory do
  uses_constants('User')

  it "should use String as key_type" do
    subject.key_type.should be(String)
  end

  it "should use uuid for next_key" do
    subject.next_key(nil).length.should == 36
  end

  describe "#eql?" do
    it "returns true for same class and key type" do
      subject.eql?(Toy::Identity::UUIDKeyFactory.new).should be_true
    end

    it "returns false for same class and different key type" do
      other = Toy::Identity::UUIDKeyFactory.new
      other.stub(:key_type).and_return(Integer)
      subject.eql?(other).should be_false
    end

    it "returns false for different classes" do
      subject.eql?(Object.new).should be_false
    end
  end

  describe "#==" do
    it "returns true for same class and key type" do
      subject.==(Toy::Identity::UUIDKeyFactory.new).should be_true
    end

    it "returns false for same class and different key type" do
      other = Toy::Identity::UUIDKeyFactory.new
      other.stub(:key_type).and_return(Integer)
      subject.==(other).should be_false
    end

    it "returns false for different classes" do
      subject.==(Object.new).should be_false
    end
  end

  describe "Declaring key to be uuid" do
    before(:each) do
      User.key(:uuid)
    end

    it "returns String as .key_type" do
      User.key_type.should be(String)
    end

    it "sets id attribute to String type" do
      User.attributes['id'].type.should be(String)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
toystore-0.13.0 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.12.0 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.11.0 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.10.4 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.10.3 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.10.2 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.10.1 spec/toy/identity/uuid_key_factory_spec.rb
toystore-0.10.0 spec/toy/identity/uuid_key_factory_spec.rb