/
active_record_extension_spec.rb
48 lines (37 loc) · 1.14 KB
/
active_record_extension_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'spec_helper'
describe 'ActiveRecord extension' do
before :all do
ActiveRecord::Base.establish_connection adapter: 'sqlite3', 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