Sha256: 8e2d92bc65bd2121b3b97544b1ad4f3e240685a4df6bfc73ce132877cd410cbf

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

require 'pathname'
require 'uuidtools'
require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'

describe DataMapper::Types::UUID do

  before(:all) do
    class UUIDTest
      include DataMapper::Resource

      property :id, Serial
      property :uuid, ::DataMapper::Types::UUID
    end

    UUIDTest.auto_migrate!
  end

  it "should be settable as a uuid" do
    u = UUIDTest.create(:uuid => UUID.parse('b0fc632e-d744-4821-afe3-4ea0701859ee'))

    u.uuid.should be_kind_of(UUID)
    u.uuid.to_s.should == 'b0fc632e-d744-4821-afe3-4ea0701859ee'
  end

  it "should be settable as a string" do
    u = UUIDTest.create(:uuid => 'b0fc632e-d744-4821-afe3-4ea0701859ee')

    u.uuid.should be_kind_of(UUID)
    u.uuid.to_s.should == 'b0fc632e-d744-4821-afe3-4ea0701859ee'
  end

  it "should be allowed to be null" do
    u = UUIDTest.create()

    u.uuid.should be_nil
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-types-0.9.7 spec/integration/uuid_spec.rb