ridgepole 0.7.3.beta → 0.7.3.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +38 -0
  3. data/Appraisals +2 -2
  4. data/README.md +3 -9
  5. data/Rakefile +7 -1
  6. data/bin/ridgepole +97 -108
  7. data/gemfiles/activerecord_5.2.gemfile +1 -1
  8. data/lib/ridgepole/cli/config.rb +43 -43
  9. data/lib/ridgepole/client.rb +65 -63
  10. data/lib/ridgepole/default_limit.rb +26 -24
  11. data/lib/ridgepole/delta.rb +367 -369
  12. data/lib/ridgepole/diff.rb +366 -377
  13. data/lib/ridgepole/dsl_parser.rb +22 -20
  14. data/lib/ridgepole/dsl_parser/context.rb +95 -93
  15. data/lib/ridgepole/dsl_parser/table_definition.rb +125 -123
  16. data/lib/ridgepole/dumper.rb +73 -71
  17. data/lib/ridgepole/execute_expander.rb +55 -55
  18. data/lib/ridgepole/ext/abstract_mysql_adapter/dump_auto_increment.rb +3 -3
  19. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +1 -1
  20. data/lib/ridgepole/ext/pp_sort_hash.rb +14 -14
  21. data/lib/ridgepole/ext/schema_dumper.rb +1 -1
  22. data/lib/ridgepole/external_sql_executer.rb +20 -20
  23. data/lib/ridgepole/logger.rb +17 -15
  24. data/lib/ridgepole/migration_ext.rb +6 -8
  25. data/lib/ridgepole/schema_statements_ext.rb +3 -3
  26. data/lib/ridgepole/version.rb +1 -1
  27. data/ridgepole.gemspec +11 -10
  28. data/spec/cli_helper.rb +2 -2
  29. data/spec/erb_helper.rb +6 -2
  30. data/spec/hide_pending_formatter.rb +5 -4
  31. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +8 -8
  32. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +8 -8
  33. data/spec/mysql/bigint_pk/int_pk_spec.rb +13 -13
  34. data/spec/mysql/cli/config_spec.rb +52 -53
  35. data/spec/mysql/cli/ridgepole_spec.rb +111 -111
  36. data/spec/mysql/collation/collation_spec.rb +39 -39
  37. data/spec/mysql/comment/comment_spec.rb +36 -36
  38. data/spec/mysql/default_lambda/default_lambda_spec.rb +30 -30
  39. data/spec/mysql/diff/diff2_spec.rb +18 -18
  40. data/spec/mysql/diff/diff_spec.rb +11 -11
  41. data/spec/mysql/dump/dump_class_method_spec.rb +2 -2
  42. data/spec/mysql/dump/dump_some_tables_spec.rb +14 -14
  43. data/spec/mysql/dump/dump_spec.rb +2 -2
  44. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +3 -3
  45. data/spec/mysql/dump/dump_without_table_options_spec.rb +8 -8
  46. data/spec/mysql/fk/migrate_change_fk_spec.rb +40 -40
  47. data/spec/mysql/fk/migrate_create_fk_spec.rb +40 -40
  48. data/spec/mysql/fk/migrate_drop_fk_spec.rb +60 -60
  49. data/spec/mysql/migrate/check_orphan_index_spec.rb +6 -6
  50. data/spec/mysql/migrate/migrate_add_column2_spec.rb +43 -43
  51. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +50 -50
  52. data/spec/mysql/migrate/migrate_add_column_spec.rb +11 -11
  53. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +8 -8
  54. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +11 -11
  55. data/spec/mysql/migrate/migrate_change_column2_spec.rb +20 -20
  56. data/spec/mysql/migrate/migrate_change_column3_spec.rb +60 -60
  57. data/spec/mysql/migrate/migrate_change_column4_spec.rb +16 -16
  58. data/spec/mysql/migrate/migrate_change_column5_spec.rb +24 -24
  59. data/spec/mysql/migrate/migrate_change_column6_spec.rb +40 -40
  60. data/spec/mysql/migrate/migrate_change_column7_spec.rb +4 -4
  61. data/spec/mysql/migrate/migrate_change_column8_spec.rb +9 -9
  62. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +48 -48
  63. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
  64. data/spec/mysql/migrate/migrate_change_column_spec.rb +11 -11
  65. data/spec/mysql/migrate/migrate_change_index2_spec.rb +20 -20
  66. data/spec/mysql/migrate/migrate_change_index3_spec.rb +43 -43
  67. data/spec/mysql/migrate/migrate_change_index4_spec.rb +24 -24
  68. data/spec/mysql/migrate/migrate_change_index5_spec.rb +16 -16
  69. data/spec/mysql/migrate/migrate_change_index6_spec.rb +12 -12
  70. data/spec/mysql/migrate/migrate_change_index7_spec.rb +20 -20
  71. data/spec/mysql/migrate/migrate_change_index8_spec.rb +20 -20
  72. data/spec/mysql/migrate/migrate_change_index_spec.rb +17 -17
  73. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +10 -10
  74. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +18 -18
  75. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +37 -37
  76. data/spec/mysql/migrate/migrate_create_index2_spec.rb +12 -12
  77. data/spec/mysql/migrate/migrate_create_index_spec.rb +11 -11
  78. data/spec/mysql/migrate/migrate_create_table_spec.rb +8 -8
  79. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +6 -6
  80. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +12 -12
  81. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +11 -11
  82. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +9 -9
  83. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +12 -12
  84. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +10 -10
  85. data/spec/mysql/migrate/migrate_drop_column_spec.rb +11 -11
  86. data/spec/mysql/migrate/migrate_drop_index_spec.rb +11 -11
  87. data/spec/mysql/migrate/migrate_drop_table_spec.rb +8 -8
  88. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +6 -6
  89. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +6 -6
  90. data/spec/mysql/migrate/migrate_empty_spec.rb +4 -4
  91. data/spec/mysql/migrate/migrate_execute_spec.rb +55 -55
  92. data/spec/mysql/migrate/migrate_log_file_spec.rb +9 -9
  93. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +9 -9
  94. data/spec/mysql/migrate/migrate_noop_spec.rb +19 -19
  95. data/spec/mysql/migrate/migrate_primary_key_spec.rb +18 -18
  96. data/spec/mysql/migrate/migrate_rename_column_spec.rb +17 -17
  97. data/spec/mysql/migrate/migrate_rename_table_spec.rb +26 -26
  98. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +16 -16
  99. data/spec/mysql/migrate/migrate_same_spec.rb +4 -4
  100. data/spec/mysql/migrate/migrate_script_error_spec.rb +8 -8
  101. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +8 -8
  102. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +9 -9
  103. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +8 -8
  104. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +9 -9
  105. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +64 -64
  106. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +12 -12
  107. data/spec/mysql/migrate/migrate_with_tables_spec.rb +29 -29
  108. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +18 -18
  109. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +8 -8
  110. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +8 -8
  111. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +8 -8
  112. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +12 -12
  113. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +30 -30
  114. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +22 -22
  115. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +7 -7
  116. data/spec/mysql57/json/add_json_column_spec.rb +8 -8
  117. data/spec/mysql57/json/change_json_column_spec.rb +24 -24
  118. data/spec/mysql57/json/drop_json_column_spec.rb +8 -8
  119. data/spec/mysql57/virtual/add_virtual_column_spec.rb +9 -9
  120. data/spec/mysql57/virtual/change_virtual_column_spec.rb +9 -9
  121. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +9 -9
  122. data/spec/postgresql/diff/diff_spec.rb +18 -18
  123. data/spec/postgresql/dump/dump_spec.rb +2 -2
  124. data/spec/postgresql/fk/migrate_change_fk_spec.rb +24 -24
  125. data/spec/postgresql/fk/migrate_create_fk_spec.rb +40 -40
  126. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +44 -44
  127. data/spec/postgresql/migrate/migrate_add_column_spec.rb +21 -21
  128. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +2 -2
  129. data/spec/postgresql/migrate/migrate_bigint_spec.rb +12 -12
  130. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +8 -8
  131. data/spec/postgresql/migrate/migrate_change_column_spec.rb +19 -19
  132. data/spec/postgresql/migrate/migrate_change_index_spec.rb +13 -13
  133. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +19 -19
  134. data/spec/postgresql/migrate/migrate_create_table_spec.rb +8 -8
  135. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +18 -18
  136. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +11 -11
  137. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +12 -12
  138. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +8 -8
  139. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +11 -11
  140. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +8 -8
  141. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +8 -8
  142. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +97 -0
  143. data/spec/postgresql/migrate/migrate_references_spec.rb +24 -24
  144. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +11 -11
  145. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +16 -16
  146. data/spec/postgresql/migrate/migrate_same_spec.rb +4 -4
  147. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +12 -12
  148. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +30 -30
  149. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +22 -22
  150. data/spec/processing_for_travis.rb +1 -1
  151. data/spec/spec_condition.rb +2 -2
  152. data/spec/spec_const.rb +9 -9
  153. data/spec/spec_helper.rb +21 -23
  154. metadata +54 -37
@@ -4,7 +4,7 @@ describe 'Ridgepole::Client#dump' do
4
4
  subject { client }
5
5
 
6
6
  it {
7
- expect(subject.dump).to match_fuzzy erbh(<<-EOS)
7
+ expect(subject.dump).to match_fuzzy erbh(<<-ERB)
8
8
  create_table "clubs", <%= i cond('>= 5.1',id: :serial) + {force: :cascade} %> do |t|
9
9
  t.string "name", limit: 255, default: "", null: false
10
10
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -61,7 +61,7 @@ describe 'Ridgepole::Client#dump' do
61
61
  t.date "to_date"
62
62
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
63
63
  end
64
- EOS
64
+ ERB
65
65
  }
66
66
  end
67
67
  end
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change fk' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "parent", force: :cascade do |t|
6
6
  end
7
7
 
@@ -11,11 +11,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
11
11
  end
12
12
 
13
13
  add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
14
- EOS
15
- }
14
+ ERB
15
+ end
16
16
 
17
- let(:sorted_actual_dsl) {
18
- erbh(<<-EOS)
17
+ let(:sorted_actual_dsl) do
18
+ erbh(<<-ERB)
19
19
  create_table "child", force: :cascade do |t|
20
20
  t.integer "parent_id"
21
21
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -25,11 +25,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
25
25
  end
26
26
 
27
27
  add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
28
- EOS
29
- }
28
+ ERB
29
+ end
30
30
 
31
- let(:expected_dsl) {
32
- erbh(<<-EOS)
31
+ let(:expected_dsl) do
32
+ erbh(<<-ERB)
33
33
  create_table "child", force: :cascade do |t|
34
34
  t.integer "parent_id"
35
35
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -39,8 +39,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
39
39
  end
40
40
 
41
41
  add_foreign_key "child", "parent", name: "child_ibfk_1"
42
- EOS
43
- }
42
+ ERB
43
+ end
44
44
 
45
45
  before { subject.diff(actual_dsl).migrate }
46
46
 
@@ -56,8 +56,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
56
56
  end
57
57
 
58
58
  context 'when change fk without name' do
59
- let(:actual_dsl) {
60
- erbh(<<-EOS)
59
+ let(:actual_dsl) do
60
+ erbh(<<-ERB)
61
61
  create_table "parent", force: :cascade do |t|
62
62
  end
63
63
 
@@ -67,11 +67,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
67
67
  end
68
68
 
69
69
  add_foreign_key "child", "parent", on_delete: :cascade
70
- EOS
71
- }
70
+ ERB
71
+ end
72
72
 
73
- let(:sorted_actual_dsl) {
74
- erbh(<<-EOS)
73
+ let(:sorted_actual_dsl) do
74
+ erbh(<<-ERB)
75
75
  create_table "child", force: :cascade do |t|
76
76
  t.integer "parent_id"
77
77
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -81,11 +81,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
81
81
  end
82
82
 
83
83
  add_foreign_key "child", "parent", on_delete: :cascade
84
- EOS
85
- }
84
+ ERB
85
+ end
86
86
 
87
- let(:expected_dsl) {
88
- erbh(<<-EOS)
87
+ let(:expected_dsl) do
88
+ erbh(<<-ERB)
89
89
  create_table "child", force: :cascade do |t|
90
90
  t.integer "parent_id"
91
91
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -95,8 +95,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
95
95
  end
96
96
 
97
97
  add_foreign_key "child", "parent"
98
- EOS
99
- }
98
+ ERB
99
+ end
100
100
 
101
101
  before { subject.diff(actual_dsl).migrate }
102
102
 
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create fk' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "child", force: :cascade do |t|
6
6
  t.integer "parent_id"
7
7
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -9,14 +9,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
9
9
 
10
10
  create_table "parent", force: :cascade do |t|
11
11
  end
12
- EOS
13
- }
12
+ ERB
13
+ end
14
14
 
15
- let(:expected_dsl) {
16
- actual_dsl + (<<-EOS)
15
+ let(:expected_dsl) do
16
+ actual_dsl + <<-RUBY
17
17
  add_foreign_key "child", "parent", name: "child_ibfk_1"
18
- EOS
19
- }
18
+ RUBY
19
+ end
20
20
 
21
21
  before { subject.diff(actual_dsl).migrate }
22
22
  subject { client }
@@ -33,17 +33,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
33
33
  delta = client(bulk_change: true).diff(expected_dsl)
34
34
  expect(delta.differ?).to be_truthy
35
35
  expect(subject.dump).to match_ruby actual_dsl
36
- expect(delta.script).to match_fuzzy <<-EOS
36
+ expect(delta.script).to match_fuzzy <<-RUBY
37
37
  add_foreign_key("child", "parent", {:name=>"child_ibfk_1"})
38
- EOS
38
+ RUBY
39
39
  delta.migrate
40
40
  expect(subject.dump).to match_ruby expected_dsl
41
41
  }
42
42
  end
43
43
 
44
44
  context 'when create fk when create table' do
45
- let(:dsl) {
46
- erbh(<<-EOS)
45
+ let(:dsl) do
46
+ erbh(<<-ERB)
47
47
  # Define parent before child
48
48
  create_table "parent", force: :cascade do |t|
49
49
  end
@@ -54,11 +54,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
54
54
  end
55
55
 
56
56
  add_foreign_key "child", "parent", name: "child_ibfk_1"
57
- EOS
58
- }
57
+ ERB
58
+ end
59
59
 
60
- let(:sorted_dsl) {
61
- erbh(<<-EOS)
60
+ let(:sorted_dsl) do
61
+ erbh(<<-ERB)
62
62
  create_table "child", force: :cascade do |t|
63
63
  t.integer "parent_id"
64
64
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -68,8 +68,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
68
68
  end
69
69
 
70
70
  add_foreign_key "child", "parent", name: "child_ibfk_1"
71
- EOS
72
- }
71
+ ERB
72
+ end
73
73
 
74
74
  before { client.diff('').migrate }
75
75
  subject { client }
@@ -84,8 +84,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
84
84
  end
85
85
 
86
86
  context 'already defined' do
87
- let(:dsl) {
88
- erbh(<<-EOS)
87
+ let(:dsl) do
88
+ erbh(<<-ERB)
89
89
  # Define parent before child
90
90
  create_table "parent", force: :cascade do |t|
91
91
  end
@@ -98,21 +98,21 @@ describe 'Ridgepole::Client#diff -> migrate' do
98
98
  add_foreign_key "child", "parent", name: "child_ibfk_1"
99
99
 
100
100
  add_foreign_key "child", "parent", name: "child_ibfk_1"
101
- EOS
102
- }
101
+ ERB
102
+ end
103
103
 
104
104
  subject { client }
105
105
 
106
106
  it {
107
- expect {
107
+ expect do
108
108
  subject.diff(dsl)
109
- }.to raise_error('Foreign Key `child(child_ibfk_1)` already defined')
109
+ end.to raise_error('Foreign Key `child(child_ibfk_1)` already defined')
110
110
  }
111
111
  end
112
112
 
113
113
  context 'when create fk without name' do
114
- let(:actual_dsl) {
115
- erbh(<<-EOS)
114
+ let(:actual_dsl) do
115
+ erbh(<<-ERB)
116
116
  create_table "child", force: :cascade do |t|
117
117
  t.integer "parent_id"
118
118
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -120,14 +120,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
120
120
 
121
121
  create_table "parent", force: :cascade do |t|
122
122
  end
123
- EOS
124
- }
123
+ ERB
124
+ end
125
125
 
126
- let(:expected_dsl) {
127
- actual_dsl + (<<-EOS)
126
+ let(:expected_dsl) do
127
+ actual_dsl + <<-RUBY
128
128
  add_foreign_key "child", "parent"
129
- EOS
130
- }
129
+ RUBY
130
+ end
131
131
 
132
132
  before { subject.diff(actual_dsl).migrate }
133
133
  subject { client }
@@ -144,31 +144,31 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  delta = client(bulk_change: true).diff(expected_dsl)
145
145
  expect(delta.differ?).to be_truthy
146
146
  expect(subject.dump).to match_ruby actual_dsl
147
- expect(delta.script).to match_fuzzy <<-EOS
147
+ expect(delta.script).to match_fuzzy <<-RUBY
148
148
  add_foreign_key("child", "parent", {})
149
- EOS
149
+ RUBY
150
150
  delta.migrate
151
151
  expect(subject.dump).to match_ruby expected_dsl
152
152
  }
153
153
  end
154
154
 
155
155
  context 'orphan fk' do
156
- let(:dsl) {
157
- erbh(<<-EOS)
156
+ let(:dsl) do
157
+ erbh(<<-ERB)
158
158
  # Define parent before child
159
159
  create_table "parent", force: :cascade do |t|
160
160
  end
161
161
 
162
162
  add_foreign_key "child", "parent", name: "child_ibfk_1"
163
- EOS
164
- }
163
+ ERB
164
+ end
165
165
 
166
166
  subject { client }
167
167
 
168
168
  it {
169
- expect {
169
+ expect do
170
170
  subject.diff(dsl)
171
- }.to raise_error('Table `child` to create the foreign key is not defined: child_ibfk_1')
171
+ end.to raise_error('Table `child` to create the foreign key is not defined: child_ibfk_1')
172
172
  }
173
173
  end
174
174
  end
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when drop fk' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "parent", force: :cascade do |t|
6
6
  end
7
7
 
@@ -11,17 +11,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
11
11
  end
12
12
 
13
13
  add_foreign_key "child", "parent", name: "child_ibfk_1"
14
- EOS
15
- }
14
+ ERB
15
+ end
16
16
 
17
- let(:sorted_actual_dsl) {
18
- expected_dsl + (<<-EOS)
17
+ let(:sorted_actual_dsl) do
18
+ expected_dsl + <<-RUBY
19
19
  add_foreign_key "child", "parent", name: "child_ibfk_1"
20
- EOS
21
- }
20
+ RUBY
21
+ end
22
22
 
23
- let(:expected_dsl) {
24
- erbh(<<-EOS)
23
+ let(:expected_dsl) do
24
+ erbh(<<-ERB)
25
25
  create_table "child", force: :cascade do |t|
26
26
  t.integer "parent_id"
27
27
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -29,8 +29,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
29
29
 
30
30
  create_table "parent", force: :cascade do |t|
31
31
  end
32
- EOS
33
- }
32
+ ERB
33
+ end
34
34
 
35
35
  before { subject.diff(actual_dsl).migrate }
36
36
  subject { client }
@@ -47,17 +47,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
47
47
  delta = client(bulk_change: true).diff(expected_dsl)
48
48
  expect(delta.differ?).to be_truthy
49
49
  expect(subject.dump).to match_fuzzy sorted_actual_dsl
50
- expect(delta.script).to match_fuzzy <<-EOS
50
+ expect(delta.script).to match_fuzzy <<-RUBY
51
51
  remove_foreign_key("child", {:name=>"child_ibfk_1"})
52
- EOS
52
+ RUBY
53
53
  delta.migrate
54
54
  expect(subject.dump).to match_ruby expected_dsl
55
55
  }
56
56
  end
57
57
 
58
58
  context 'when drop fk when drop table' do
59
- let(:dsl) {
60
- erbh(<<-EOS)
59
+ let(:dsl) do
60
+ erbh(<<-ERB)
61
61
  create_table "parent", force: :cascade do |t|
62
62
  end
63
63
 
@@ -67,11 +67,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
67
67
  end
68
68
 
69
69
  add_foreign_key "child", "parent", name: "child_ibfk_1"
70
- EOS
71
- }
70
+ ERB
71
+ end
72
72
 
73
- let(:sorted_dsl) {
74
- erbh(<<-EOS)
73
+ let(:sorted_dsl) do
74
+ erbh(<<-ERB)
75
75
  create_table "child", force: :cascade do |t|
76
76
  t.integer "parent_id"
77
77
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
81
81
  end
82
82
 
83
83
  add_foreign_key "child", "parent", name: "child_ibfk_1"
84
- EOS
85
- }
84
+ ERB
85
+ end
86
86
 
87
87
  before { subject.diff(dsl).migrate }
88
88
  subject { client }
@@ -97,8 +97,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
97
97
  end
98
98
 
99
99
  context 'when drop fk without name' do
100
- let(:actual_dsl) {
101
- erbh(<<-EOS)
100
+ let(:actual_dsl) do
101
+ erbh(<<-ERB)
102
102
  create_table "parent", force: :cascade do |t|
103
103
  end
104
104
 
@@ -108,17 +108,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
108
108
  end
109
109
 
110
110
  add_foreign_key "child", "parent"
111
- EOS
112
- }
111
+ ERB
112
+ end
113
113
 
114
- let(:sorted_actual_dsl) {
115
- expected_dsl + (<<-EOS)
114
+ let(:sorted_actual_dsl) do
115
+ expected_dsl + <<-RUBY
116
116
  add_foreign_key "child", "parent"
117
- EOS
118
- }
117
+ RUBY
118
+ end
119
119
 
120
- let(:expected_dsl) {
121
- erbh(<<-EOS)
120
+ let(:expected_dsl) do
121
+ erbh(<<-ERB)
122
122
  create_table "child", force: :cascade do |t|
123
123
  t.integer "parent_id"
124
124
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -126,8 +126,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
126
126
 
127
127
  create_table "parent", force: :cascade do |t|
128
128
  end
129
- EOS
130
- }
129
+ ERB
130
+ end
131
131
 
132
132
  before { subject.diff(actual_dsl).migrate }
133
133
  subject { client }
@@ -144,17 +144,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  delta = client(bulk_change: true).diff(expected_dsl)
145
145
  expect(delta.differ?).to be_truthy
146
146
  expect(subject.dump).to match_fuzzy sorted_actual_dsl
147
- expect(delta.script).to match_fuzzy <<-EOS
147
+ expect(delta.script).to match_fuzzy <<-RUBY
148
148
  remove_foreign_key("child", "parent")
149
- EOS
149
+ RUBY
150
150
  delta.migrate
151
151
  expect(subject.dump).to match_ruby expected_dsl
152
152
  }
153
153
  end
154
154
 
155
155
  context 'when drop fk when drop table without name' do
156
- let(:dsl) {
157
- erbh(<<-EOS)
156
+ let(:dsl) do
157
+ erbh(<<-ERB)
158
158
  create_table "parent", force: :cascade do |t|
159
159
  end
160
160
 
@@ -164,11 +164,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
164
164
  end
165
165
 
166
166
  add_foreign_key "child", "parent"
167
- EOS
168
- }
167
+ ERB
168
+ end
169
169
 
170
- let(:sorted_dsl) {
171
- erbh(<<-EOS)
170
+ let(:sorted_dsl) do
171
+ erbh(<<-ERB)
172
172
  create_table "child", force: :cascade do |t|
173
173
  t.integer "parent_id"
174
174
  t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
@@ -178,8 +178,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
178
178
  end
179
179
 
180
180
  add_foreign_key "child", "parent"
181
- EOS
182
- }
181
+ ERB
182
+ end
183
183
 
184
184
  before { subject.diff(dsl).migrate }
185
185
  subject { client }