Skip to content

Commit 7263d55

Browse files
committed
Refactor options of AnnotateModels.get_schema_info
1 parent dfb04ed commit 7263d55

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def mock_column(name, type, options = {})
177177

178178
describe '.get_schema_info' do
179179
subject do
180-
AnnotateModels.get_schema_info(klass, header)
180+
AnnotateModels.get_schema_info(klass, header, **options)
181181
end
182182

183183
let :klass do
@@ -193,8 +193,8 @@ def mock_column(name, type, options = {})
193193
end
194194

195195
context 'when option is not present' do
196-
subject do
197-
AnnotateModels.get_schema_info(klass, header)
196+
let :options do
197+
{}
198198
end
199199

200200
context 'when header is "Schema Info"' do
@@ -476,8 +476,8 @@ def mock_column(name, type, options = {})
476476

477477
context 'when indexes exist' do
478478
context 'when option "show_indexes" is true' do
479-
subject do
480-
AnnotateModels.get_schema_info(klass, header, show_indexes: true)
479+
let :options do
480+
{ show_indexes: true }
481481
end
482482

483483
context 'when indexes are normal' do
@@ -677,8 +677,8 @@ def mock_column(name, type, options = {})
677677
end
678678

679679
context 'when option "simple_indexes" is true' do
680-
subject do
681-
AnnotateModels.get_schema_info(klass, header, simple_indexes: true)
680+
let :options do
681+
{ simple_indexes: true }
682682
end
683683

684684
context 'when one of indexes includes "orders" clause' do
@@ -766,8 +766,8 @@ def mock_column(name, type, options = {})
766766
end
767767

768768
context 'when option "show_foreign_keys" is specified' do
769-
subject do
770-
AnnotateModels.get_schema_info(klass, header, show_foreign_keys: true)
769+
let :options do
770+
{ show_foreign_keys: true }
771771
end
772772

773773
context 'when foreign_keys does not have option' do
@@ -829,8 +829,8 @@ def mock_column(name, type, options = {})
829829
end
830830

831831
context 'when option "show_foreign_keys" and "show_complete_foreign_keys" are specified' do
832-
subject do
833-
AnnotateModels.get_schema_info(klass, header, show_foreign_keys: true, show_complete_foreign_keys: true)
832+
let :options do
833+
{ show_foreign_keys: true, show_complete_foreign_keys: true }
834834
end
835835

836836
let :expected_result do
@@ -879,8 +879,8 @@ def mock_column(name, type, options = {})
879879
end
880880

881881
context 'when option "format_rdoc" is true' do
882-
subject do
883-
AnnotateModels.get_schema_info(klass, header, format_rdoc: true)
882+
let :options do
883+
{ format_rdoc: true }
884884
end
885885

886886
let :expected_result do
@@ -903,8 +903,8 @@ def mock_column(name, type, options = {})
903903
end
904904

905905
context 'when option "format_yard" is true' do
906-
subject do
907-
AnnotateModels.get_schema_info(klass, header, format_yard: true)
906+
let :options do
907+
{ format_yard: true }
908908
end
909909

910910
let :expected_result do
@@ -928,8 +928,8 @@ def mock_column(name, type, options = {})
928928

929929
context 'when option "format_markdown" is true' do
930930
context 'when other option is not specified' do
931-
subject do
932-
AnnotateModels.get_schema_info(klass, header, format_markdown: true)
931+
let :options do
932+
{ format_markdown: true }
933933
end
934934

935935
let :expected_result do
@@ -954,8 +954,8 @@ def mock_column(name, type, options = {})
954954
end
955955

956956
context 'when option "show_indexes" is true' do
957-
subject do
958-
AnnotateModels.get_schema_info(klass, header, format_markdown: true, show_indexes: true)
957+
let :options do
958+
{ format_markdown: true, show_indexes: true }
959959
end
960960

961961
context 'when indexes are normal' do
@@ -1149,8 +1149,8 @@ def mock_column(name, type, options = {})
11491149
end
11501150

11511151
context 'when option "show_foreign_keys" is true' do
1152-
subject do
1153-
AnnotateModels.get_schema_info(klass, header, format_markdown: true, show_foreign_keys: true)
1152+
let :options do
1153+
{ format_markdown: true, show_foreign_keys: true }
11541154
end
11551155

11561156
let :columns do
@@ -1623,8 +1623,8 @@ def mock_column(name, type, options = {})
16231623
end
16241624

16251625
context 'when "format_doc" and "with_comment" are specified in options' do
1626-
subject do
1627-
AnnotateModels.get_schema_info(klass, AnnotateModels::PREFIX, format_rdoc: true, with_comment: true)
1626+
let :options do
1627+
{ format_rdoc: true, with_comment: true }
16281628
end
16291629

16301630
context 'when columns are normal' do
@@ -1656,8 +1656,8 @@ def mock_column(name, type, options = {})
16561656
end
16571657

16581658
context 'when "format_markdown" and "with_comment" are specified in options' do
1659-
subject do
1660-
AnnotateModels.get_schema_info(klass, AnnotateModels::PREFIX, format_markdown: true, with_comment: true)
1659+
let :options do
1660+
{ format_markdown: true, with_comment: true }
16611661
end
16621662

16631663
context 'when columns have comments' do

0 commit comments

Comments
 (0)