forked from datamapper/dm-migrations
/
sample_migration_spec.rb
50 lines (37 loc) · 1.29 KB
/
sample_migration_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
49
50
require 'pathname'
dir = Pathname(__FILE__).dirname.expand_path
require dir + 'sample_migration'
require dir + '../lib/spec/example/migration_example_group'
describe :create_people_table, :type => :migration do
before do
run_migration
end
it 'should create a people table' do
repository(:default).should have_table(:people)
end
it 'should have an id column as the primary key' do
table(:people).should have_column(:id)
table(:people).column(:id).type.should == 'integer'
#table(:people).column(:id).should be_primary_key
end
it 'should have a name column as a string' do
table(:people).should have_column(:name)
table(:people).column(:name).type.should == 'character varying'
table(:people).column(:name).should permit_null
end
it 'should have a nullable age column as a int' do
table(:people).should have_column(:age)
table(:people).column(:age).type.should == 'integer'
table(:people).column(:age).should permit_null
end
end
describe :add_dob_to_people, :type => :migration do
before do
run_migration
end
it 'should add a dob column as a timestamp' do
table(:people).should have_column(:dob)
table(:people).column(:dob).type.should == 'timestamp without time zone'
table(:people).column(:dob).should permit_null
end
end