Sha256: cbfb964b7faaf460e02811448c233b061c2c437a48a8b83746788ea4b4124949

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe 'ActiveRecord extension' do

  before :all do
    ActiveRecord::Base.establish_connection adapter: SQLITE_ADAPTER, database: ":memory:"
    ActiveRecord::Base.connection
    ActiveRecord::Migrator.migrate ActiveRecord::Migrator.migrations_path
  end

  context 'Attribute uuid' do

    it 'Migration type' do
      Country.primary_key.should eq 'id'
      uuid_column = Country.columns_hash['key']
      uuid_column.type.should eq :string
      uuid_column.limit.should eq 36
      uuid_column.null.should be true
    end

    it 'ActiveRecord generation' do
      model = Country.create!
      model.key.should be_a String
      model.key.size.should eq 36
    end

  end

  context 'Primary key uuid' do

    it 'Migration type' do
      Language.primary_key.should eq 'id'
      uuid_column = Language.columns_hash['id']
      uuid_column.type.should eq :string
      uuid_column.limit.should eq 36
      uuid_column.primary.should be true
      uuid_column.null.should be false
    end

    it 'ActiveRecord generation' do
      model = Language.create!
      model.id.should be_a String
      model.id.size.should eq 36
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord_uuid-0.0.2 spec/active_record_extension_spec.rb