@@ -427,6 +427,37 @@ def mock_column(name, type, options = {})
427
427
end
428
428
end
429
429
end
430
+
431
+ context 'when the primary key is an array (using composite_primary_keys)' do
432
+ let :primary_key do
433
+ [ :a_id , :b_id ]
434
+ end
435
+
436
+ let :columns do
437
+ [
438
+ mock_column ( :a_id , :integer ) ,
439
+ mock_column ( :b_id , :integer ) ,
440
+ mock_column ( :name , :string , limit : 50 )
441
+ ]
442
+ end
443
+
444
+ let :expected_result do
445
+ <<~EOS
446
+ # Schema Info
447
+ #
448
+ # Table name: users
449
+ #
450
+ # a_id :integer not null, primary key
451
+ # b_id :integer not null, primary key
452
+ # name :string(50) not null
453
+ #
454
+ EOS
455
+ end
456
+
457
+ it 'returns schema info' do
458
+ is_expected . to eq ( expected_result )
459
+ end
460
+ end
430
461
end
431
462
end
432
463
end
@@ -830,45 +861,6 @@ def mock_column(name, type, options = {})
830
861
end
831
862
end
832
863
833
- context 'when header is "Schema Info"' do
834
- let :header do
835
- 'Schema Info'
836
- end
837
-
838
- context 'when the primary key is specified' do
839
- context 'when the primary key is an array (using composite_primary_keys)' do
840
- let :primary_key do
841
- [ :a_id , :b_id ]
842
- end
843
-
844
- let :columns do
845
- [
846
- mock_column ( :a_id , :integer ) ,
847
- mock_column ( :b_id , :integer ) ,
848
- mock_column ( :name , :string , limit : 50 )
849
- ]
850
- end
851
-
852
- let :expected_result do
853
- <<~EOS
854
- # Schema Info
855
- #
856
- # Table name: users
857
- #
858
- # a_id :integer not null, primary key
859
- # b_id :integer not null, primary key
860
- # name :string(50) not null
861
- #
862
- EOS
863
- end
864
-
865
- it 'returns schema info' do
866
- is_expected . to eq ( expected_result )
867
- end
868
- end
869
- end
870
- end
871
-
872
864
context 'when header is "== Schema Information"' do
873
865
let :header do
874
866
AnnotateModels ::PREFIX
0 commit comments