ridgepole 0.6.4 → 0.6.5.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +18 -8
  4. data/Appraisals +8 -0
  5. data/README.md +26 -2
  6. data/docker-compose.yml +12 -0
  7. data/gemfiles/activerecord_4.2.gemfile +8 -0
  8. data/gemfiles/activerecord_5.0.gemfile +7 -0
  9. data/lib/ridgepole/diff.rb +3 -1
  10. data/lib/ridgepole/version.rb +1 -1
  11. data/ridgepole.gemspec +6 -2
  12. data/spec/cli_helper.rb +63 -0
  13. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +45 -0
  14. data/spec/mysql/cli/config_spec.rb +0 -2
  15. data/spec/mysql/cli/ridgepole_spec.rb +58 -56
  16. data/spec/mysql/collation/collation_spec.rb +134 -138
  17. data/spec/mysql/diff/diff2_spec.rb +1 -3
  18. data/spec/mysql/diff/diff_spec.rb +1 -3
  19. data/spec/mysql/dump/dump_class_method_spec.rb +29 -11
  20. data/spec/mysql/dump/dump_some_tables_spec.rb +18 -8
  21. data/spec/mysql/dump/dump_spec.rb +28 -10
  22. data/spec/mysql/dump/dump_without_table_options_spec.rb +29 -33
  23. data/spec/mysql/fk/migrate_change_fk_spec.rb +2 -4
  24. data/spec/mysql/fk/migrate_create_fk_spec.rb +39 -29
  25. data/spec/mysql/fk/migrate_drop_fk_spec.rb +20 -22
  26. data/spec/mysql/migrate/check_orphan_index_spec.rb +2 -4
  27. data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -26
  28. data/spec/mysql/migrate/migrate_add_column_spec.rb +32 -22
  29. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +26 -16
  30. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +27 -17
  31. data/spec/mysql/migrate/migrate_change_column2_spec.rb +26 -16
  32. data/spec/mysql/migrate/migrate_change_column3_spec.rb +54 -44
  33. data/spec/mysql/migrate/migrate_change_column4_spec.rb +8 -10
  34. data/spec/mysql/migrate/migrate_change_column5_spec.rb +32 -22
  35. data/spec/mysql/migrate/migrate_change_column6_spec.rb +28 -30
  36. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +34 -36
  37. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +10 -12
  38. data/spec/mysql/migrate/migrate_change_column_spec.rb +41 -29
  39. data/spec/mysql/migrate/migrate_change_index2_spec.rb +12 -14
  40. data/spec/mysql/migrate/migrate_change_index3_spec.rb +24 -26
  41. data/spec/mysql/migrate/migrate_change_index4_spec.rb +34 -24
  42. data/spec/mysql/migrate/migrate_change_index5_spec.rb +26 -16
  43. data/spec/mysql/migrate/migrate_change_index6_spec.rb +38 -28
  44. data/spec/mysql/migrate/migrate_change_index_spec.rb +39 -29
  45. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +26 -13
  46. data/spec/mysql/migrate/migrate_create_index2_spec.rb +30 -20
  47. data/spec/mysql/migrate/migrate_create_index_spec.rb +28 -18
  48. data/spec/mysql/migrate/migrate_create_table_spec.rb +24 -14
  49. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +4 -6
  50. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +23 -13
  51. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +32 -22
  52. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +35 -25
  53. data/spec/mysql/migrate/migrate_drop_column_spec.rb +36 -26
  54. data/spec/mysql/migrate/migrate_drop_index_spec.rb +28 -18
  55. data/spec/mysql/migrate/migrate_drop_table_spec.rb +29 -19
  56. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +2 -4
  57. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +2 -4
  58. data/spec/mysql/migrate/migrate_empty_spec.rb +24 -14
  59. data/spec/mysql/migrate/migrate_execute_spec.rb +78 -65
  60. data/spec/mysql/migrate/migrate_log_file_spec.rb +22 -12
  61. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +31 -21
  62. data/spec/mysql/migrate/migrate_noop_spec.rb +55 -45
  63. data/spec/mysql/migrate/migrate_rename_column_spec.rb +38 -28
  64. data/spec/mysql/migrate/migrate_rename_table_spec.rb +43 -33
  65. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +28 -18
  66. data/spec/mysql/migrate/migrate_same_spec.rb +26 -12
  67. data/spec/mysql/migrate/migrate_script_error_spec.rb +3 -5
  68. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +30 -20
  69. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +30 -20
  70. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +44 -46
  71. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +6 -8
  72. data/spec/mysql/migrate/migrate_with_tables_spec.rb +20 -22
  73. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +22 -12
  74. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +22 -12
  75. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +8 -10
  76. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +39 -29
  77. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +20 -22
  78. data/spec/postgresql/diff/diff_spec.rb +7 -9
  79. data/spec/postgresql/dump/dump_spec.rb +2 -4
  80. data/spec/postgresql/fk/migrate_change_fk_spec.rb +8 -10
  81. data/spec/postgresql/fk/migrate_create_fk_spec.rb +24 -26
  82. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +21 -23
  83. data/spec/postgresql/migrate/migrate_add_column_spec.rb +19 -22
  84. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +6 -8
  85. data/spec/postgresql/migrate/migrate_change_column_spec.rb +17 -19
  86. data/spec/postgresql/migrate/migrate_change_index_spec.rb +11 -13
  87. data/spec/postgresql/migrate/migrate_create_table_spec.rb +6 -9
  88. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +12 -14
  89. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +12 -14
  90. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +10 -12
  91. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +7 -9
  92. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -8
  93. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +12 -14
  94. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +14 -16
  95. data/spec/postgresql/migrate/migrate_same_spec.rb +4 -6
  96. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +8 -10
  97. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +24 -26
  98. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +20 -22
  99. data/spec/processing_for_travis.rb +9 -0
  100. data/spec/spec_condition.rb +24 -0
  101. data/spec/spec_const.rb +18 -0
  102. data/spec/spec_helper.rb +125 -196
  103. data/spec/string_ext.rb +0 -13
  104. metadata +106 -32
  105. data/spec/mysql/bigint_pk/bigint_pkspec.rb +0 -47
@@ -1,8 +1,7 @@
1
- unless postgresql?
2
1
  describe 'Ridgepole::Client#diff -> migrate' do
3
2
  context 'when change column (boolean without limit)' do
4
3
  let(:actual_dsl) {
5
- <<-RUBY
4
+ <<-EOS
6
5
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
7
6
  t.date "birth_date", null: false
8
7
  t.string "first_name", limit: 14, null: false
@@ -13,11 +12,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
13
12
  t.datetime "updated_at", null: false
14
13
  t.boolean "registered"
15
14
  end
16
- RUBY
15
+ EOS
17
16
  }
18
17
 
19
18
  let(:expected_dsl) {
20
- <<-RUBY
19
+ <<-EOS
21
20
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
22
21
  t.date "birth_date", null: false
23
22
  t.string "first_name", limit: 14, null: false
@@ -28,7 +27,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
28
27
  t.datetime "updated_at", null: false
29
28
  t.boolean "registered"
30
29
  end
31
- RUBY
30
+ EOS
32
31
  }
33
32
 
34
33
  before { subject.diff(actual_dsl).migrate }
@@ -42,7 +41,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
42
41
 
43
42
  context 'when change column (boolean with limit)' do
44
43
  let(:actual_dsl) {
45
- <<-RUBY
44
+ <<-EOS
46
45
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
47
46
  t.date "birth_date", null: false
48
47
  t.string "first_name", limit: 14, null: false
@@ -53,11 +52,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
53
52
  t.datetime "updated_at", null: false
54
53
  t.boolean "registered"
55
54
  end
56
- RUBY
55
+ EOS
57
56
  }
58
57
 
59
58
  let(:expected_dsl) {
60
- <<-RUBY
59
+ <<-EOS
61
60
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
62
61
  t.date "birth_date", null: false
63
62
  t.string "first_name", limit: 14, null: false
@@ -68,7 +67,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
68
67
  t.datetime "updated_at", null: false
69
68
  t.boolean "registered", limit: 1
70
69
  end
71
- RUBY
70
+ EOS
72
71
  }
73
72
 
74
73
  before { subject.diff(actual_dsl).migrate }
@@ -80,4 +79,3 @@ describe 'Ridgepole::Client#diff -> migrate' do
80
79
  }
81
80
  end
82
81
  end
83
- end
@@ -1,9 +1,20 @@
1
- unless postgresql?
2
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
+ let(:template_variables) {
3
+ opts = {
4
+ unsigned: {}
5
+ }
6
+
7
+ if condition(:mysql_awesome_enabled)
8
+ opts[:unsigned] = {unsigned: true}
9
+ end
10
+
11
+ opts
12
+ }
13
+
3
14
  context 'when change column (binary: blob -> varbinary)' do
4
15
  let(:actual_dsl) {
5
- <<-RUBY
6
- create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
16
+ erbh(<<-EOS, template_variables)
17
+ create_table "employees", primary_key: "emp_no", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
7
18
  t.date "birth_date", null: false
8
19
  t.string "first_name", limit: 14, null: false
9
20
  t.string "last_name", limit: 16, null: false
@@ -13,12 +24,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
13
24
  t.datetime "updated_at", null: false
14
25
  t.binary "registered_name", limit: 65535
15
26
  end
16
- RUBY
27
+ EOS
17
28
  }
18
29
 
19
30
  let(:expected_dsl) {
20
- <<-RUBY
21
- create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
31
+ erbh(<<-EOS, template_variables)
32
+ create_table "employees", primary_key: "emp_no", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
22
33
  t.date "birth_date", null: false
23
34
  t.string "first_name", limit: 14, null: false
24
35
  t.string "last_name", limit: 16, null: false
@@ -28,7 +39,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
28
39
  t.datetime "updated_at", null: false
29
40
  t.binary "registered_name", limit: 255
30
41
  end
31
- RUBY
42
+ EOS
32
43
  }
33
44
 
34
45
  before { subject.diff(actual_dsl).migrate }
@@ -37,16 +48,16 @@ describe 'Ridgepole::Client#diff -> migrate' do
37
48
  it {
38
49
  delta = subject.diff(expected_dsl)
39
50
  expect(delta.differ?).to be_truthy
40
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
51
+ expect(subject.dump).to match_fuzzy actual_dsl
41
52
  delta.migrate
42
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
53
+ expect(subject.dump).to match_fuzzy expected_dsl
43
54
  }
44
55
  end
45
56
 
46
57
  context 'when change column (binary: varbinary -> blob)' do
47
58
  let(:actual_dsl) {
48
- <<-RUBY
49
- create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
59
+ erbh(<<-EOS, template_variables)
60
+ create_table "employees", primary_key: "emp_no", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
50
61
  t.date "birth_date", null: false
51
62
  t.string "first_name", limit: 14, null: false
52
63
  t.string "last_name", limit: 16, null: false
@@ -56,12 +67,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
56
67
  t.datetime "updated_at", null: false
57
68
  t.binary "registered_name", limit: 255
58
69
  end
59
- RUBY
70
+ EOS
60
71
  }
61
72
 
62
73
  let(:expected_dsl) {
63
- <<-RUBY
64
- create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
74
+ erbh(<<-EOS, template_variables)
75
+ create_table "employees", primary_key: "emp_no", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
65
76
  t.date "birth_date", null: false
66
77
  t.string "first_name", limit: 14, null: false
67
78
  t.string "last_name", limit: 16, null: false
@@ -71,7 +82,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
71
82
  t.datetime "updated_at", null: false
72
83
  t.binary "registered_name", limit: 65535
73
84
  end
74
- RUBY
85
+ EOS
75
86
  }
76
87
 
77
88
  before { subject.diff(actual_dsl).migrate }
@@ -80,15 +91,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
80
91
  it {
81
92
  delta = subject.diff(expected_dsl)
82
93
  expect(delta.differ?).to be_truthy
83
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
94
+ expect(subject.dump).to match_fuzzy actual_dsl
84
95
  delta.migrate
85
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
96
+ expect(subject.dump).to match_fuzzy expected_dsl
86
97
  }
87
98
  end
88
99
 
89
100
  context 'when change column (binary without limit)' do
90
101
  let(:actual_dsl) {
91
- <<-RUBY
102
+ <<-EOS
92
103
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
93
104
  t.date "birth_date", null: false
94
105
  t.string "first_name", limit: 14, null: false
@@ -99,11 +110,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
99
110
  t.datetime "updated_at", null: false
100
111
  t.binary "registered_name", limit: 65535
101
112
  end
102
- RUBY
113
+ EOS
103
114
  }
104
115
 
105
116
  let(:expected_dsl) {
106
- <<-RUBY
117
+ <<-EOS
107
118
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
108
119
  t.date "birth_date", null: false
109
120
  t.string "first_name", limit: 14, null: false
@@ -114,7 +125,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
114
125
  t.datetime "updated_at", null: false
115
126
  t.binary "registered_name"
116
127
  end
117
- RUBY
128
+ EOS
118
129
  }
119
130
 
120
131
  before { subject.diff(actual_dsl).migrate }
@@ -126,4 +137,3 @@ describe 'Ridgepole::Client#diff -> migrate' do
126
137
  }
127
138
  end
128
139
  end
129
- end
@@ -1,8 +1,7 @@
1
- unless postgresql?
2
1
  describe 'Ridgepole::Client#diff -> migrate' do
3
2
  context 'when add column after id (pk: normal)' do
4
3
  let(:actual_dsl) {
5
- <<-RUBY
4
+ <<-EOS
6
5
  create_table "employees", force: :cascade do |t|
7
6
  t.date "birth_date", null: false
8
7
  t.string "first_name", limit: 14, null: false
@@ -13,11 +12,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
13
12
  t.datetime "updated_at", null: false
14
13
  t.binary "registered_name", limit: 65535
15
14
  end
16
- RUBY
15
+ EOS
17
16
  }
18
17
 
19
18
  let(:expected_dsl) {
20
- <<-RUBY
19
+ <<-EOS
21
20
  create_table "employees", force: :cascade do |t|
22
21
  t.string "ext_column", limit: 255, null: false
23
22
  t.date "birth_date", null: false
@@ -29,7 +28,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
29
28
  t.datetime "updated_at", null: false
30
29
  t.binary "registered_name", limit: 255
31
30
  end
32
- RUBY
31
+ EOS
33
32
  }
34
33
 
35
34
  before { subject.diff(actual_dsl).migrate }
@@ -38,11 +37,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
38
37
  it {
39
38
  delta = subject.diff(expected_dsl)
40
39
  expect(delta.differ?).to be_truthy
41
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
40
+ expect(subject.dump).to match_fuzzy actual_dsl
42
41
  delta.migrate
43
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
42
+ expect(subject.dump).to match_fuzzy expected_dsl
44
43
 
45
- expect(show_create_table_mysql('employees')).to eq <<-EOS.strip_heredoc.strip
44
+ expect(show_create_table_mysql('employees')).to match_fuzzy <<-EOS
46
45
  CREATE TABLE `employees` (
47
46
  `id` int(11) NOT NULL AUTO_INCREMENT,
48
47
  `ext_column` varchar(255) NOT NULL,
@@ -62,7 +61,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
62
61
 
63
62
  context 'when add column after id (pk: emp_id)' do
64
63
  let(:actual_dsl) {
65
- <<-RUBY
64
+ <<-EOS
66
65
  create_table "employees", primary_key: "emp_id", force: :cascade do |t|
67
66
  t.date "birth_date", null: false
68
67
  t.string "first_name", limit: 14, null: false
@@ -73,11 +72,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
73
72
  t.datetime "updated_at", null: false
74
73
  t.binary "registered_name", limit: 65535
75
74
  end
76
- RUBY
75
+ EOS
77
76
  }
78
77
 
79
78
  let(:expected_dsl) {
80
- <<-RUBY
79
+ <<-EOS
81
80
  create_table "employees", primary_key: "emp_id", force: :cascade do |t|
82
81
  t.string "ext_column", limit: 255, null: false
83
82
  t.date "birth_date", null: false
@@ -89,7 +88,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
89
88
  t.datetime "updated_at", null: false
90
89
  t.binary "registered_name", limit: 255
91
90
  end
92
- RUBY
91
+ EOS
93
92
  }
94
93
 
95
94
  before { subject.diff(actual_dsl).migrate }
@@ -98,11 +97,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
98
97
  it {
99
98
  delta = subject.diff(expected_dsl)
100
99
  expect(delta.differ?).to be_truthy
101
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
100
+ expect(subject.dump).to match_fuzzy actual_dsl
102
101
  delta.migrate
103
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
102
+ expect(subject.dump).to match_fuzzy expected_dsl
104
103
 
105
- expect(show_create_table_mysql('employees')).to eq <<-EOS.strip_heredoc.strip
104
+ expect(show_create_table_mysql('employees')).to match_fuzzy <<-EOS
106
105
  CREATE TABLE `employees` (
107
106
  `emp_id` int(11) NOT NULL AUTO_INCREMENT,
108
107
  `ext_column` varchar(255) NOT NULL,
@@ -122,7 +121,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
122
121
 
123
122
  context 'when add column after id (pk: no pk)' do
124
123
  let(:actual_dsl) {
125
- <<-RUBY
124
+ <<-EOS
126
125
  create_table "employees", id: false, force: :cascade do |t|
127
126
  t.date "birth_date", null: false
128
127
  t.string "first_name", limit: 14, null: false
@@ -133,11 +132,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
133
132
  t.datetime "updated_at", null: false
134
133
  t.binary "registered_name", limit: 65535
135
134
  end
136
- RUBY
135
+ EOS
137
136
  }
138
137
 
139
138
  let(:expected_dsl) {
140
- <<-RUBY
139
+ <<-EOS
141
140
  create_table "employees", id: false, force: :cascade do |t|
142
141
  t.string "ext_column", limit: 255, null: false
143
142
  t.date "birth_date", null: false
@@ -149,7 +148,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
149
148
  t.datetime "updated_at", null: false
150
149
  t.binary "registered_name", limit: 255
151
150
  end
152
- RUBY
151
+ EOS
153
152
  }
154
153
 
155
154
  before { subject.diff(actual_dsl).migrate }
@@ -158,11 +157,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
158
157
  it {
159
158
  delta = subject.diff(expected_dsl)
160
159
  expect(delta.differ?).to be_truthy
161
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
160
+ expect(subject.dump).to match_fuzzy actual_dsl
162
161
  delta.migrate
163
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
162
+ expect(subject.dump).to match_fuzzy expected_dsl
164
163
 
165
- expect(show_create_table_mysql('employees')).to eq <<-EOS.strip_heredoc.strip
164
+ expect(show_create_table_mysql('employees')).to match_fuzzy <<-EOS
166
165
  CREATE TABLE `employees` (
167
166
  `ext_column` varchar(255) NOT NULL,
168
167
  `birth_date` date NOT NULL,
@@ -180,7 +179,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
180
179
 
181
180
  context 'when add column after id (pk: with pk delta)' do
182
181
  let(:actual_dsl) {
183
- <<-RUBY
182
+ <<-EOS
184
183
  create_table "employees", force: :cascade do |t|
185
184
  t.date "birth_date", null: false
186
185
  t.string "first_name", limit: 14, null: false
@@ -191,11 +190,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
191
190
  t.datetime "updated_at", null: false
192
191
  t.binary "registered_name", limit: 65535
193
192
  end
194
- RUBY
193
+ EOS
195
194
  }
196
195
 
197
196
  let(:expected_dsl) {
198
- <<-RUBY
197
+ <<-EOS
199
198
  create_table "employees", primary_key: "emp_id", force: :cascade do |t|
200
199
  t.string "ext_column", limit: 255, null: false
201
200
  t.date "birth_date", null: false
@@ -207,7 +206,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
207
206
  t.datetime "updated_at", null: false
208
207
  t.binary "registered_name", limit: 255
209
208
  end
210
- RUBY
209
+ EOS
211
210
  }
212
211
 
213
212
  before { subject.diff(actual_dsl).migrate }
@@ -216,11 +215,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
216
215
  it {
217
216
  delta = subject.diff(expected_dsl)
218
217
  expect(delta.differ?).to be_truthy
219
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
218
+ expect(subject.dump).to match_fuzzy actual_dsl
220
219
  delta.migrate
221
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.sub(', primary_key: "emp_id"', '')
220
+ expect(subject.dump).to match_fuzzy expected_dsl.sub(/, *primary_key: *"emp_id"/, '')
222
221
 
223
- expect(show_create_table_mysql('employees')).to eq <<-EOS.strip_heredoc.strip
222
+ expect(show_create_table_mysql('employees')).to match_fuzzy <<-EOS
224
223
  CREATE TABLE `employees` (
225
224
  `id` int(11) NOT NULL AUTO_INCREMENT,
226
225
  `ext_column` varchar(255) NOT NULL,
@@ -238,4 +237,3 @@ describe 'Ridgepole::Client#diff -> migrate' do
238
237
  }
239
238
  end
240
239
  end
241
- end
@@ -1,37 +1,36 @@
1
- unless postgresql?
2
1
  describe 'Ridgepole::Client#diff -> migrate' do
3
2
  context 'when default:0 -> (emply)' do
4
3
  let(:actual_dsl) {
5
- <<-RUBY
4
+ <<-EOS
6
5
  create_table "salaries", id: false, force: :cascade do |t|
7
6
  t.integer "emp_no", limit: 4, default: 0, null: false
8
7
  t.float "salary", limit: 24, null: false
9
8
  t.date "from_date", null: false
10
9
  t.date "to_date", null: false
11
10
  end
12
- RUBY
11
+ EOS
13
12
  }
14
13
 
15
14
  let(:expected_dsl) {
16
- <<-RUBY
15
+ <<-EOS
17
16
  create_table "salaries", id: false, force: :cascade do |t|
18
17
  t.integer "emp_no", limit: 4, null: true
19
18
  t.float "salary", limit: 24, null: false
20
19
  t.date "from_date", null: false
21
20
  t.date "to_date", null: false
22
21
  end
23
- RUBY
22
+ EOS
24
23
  }
25
24
 
26
25
  let(:result_dsl) {
27
- <<-RUBY
26
+ <<-EOS
28
27
  create_table "salaries", id: false, force: :cascade do |t|
29
28
  t.integer "emp_no", limit: 4
30
29
  t.float "salary", limit: 24, null: false
31
30
  t.date "from_date", null: false
32
31
  t.date "to_date", null: false
33
32
  end
34
- RUBY
33
+ EOS
35
34
  }
36
35
 
37
36
  before { subject.diff(actual_dsl).migrate }
@@ -40,33 +39,33 @@ describe 'Ridgepole::Client#diff -> migrate' do
40
39
  it {
41
40
  delta = subject.diff(expected_dsl)
42
41
  expect(delta.differ?).to be_truthy
43
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
42
+ expect(subject.dump).to match_fuzzy actual_dsl
44
43
  delta.migrate
45
- expect(subject.dump).to eq result_dsl.strip_heredoc.strip
44
+ expect(subject.dump).to match_fuzzy result_dsl
46
45
  }
47
46
  end
48
47
 
49
48
  context 'when default:0 -> (emply with null:false)' do
50
49
  let(:actual_dsl) {
51
- <<-RUBY
50
+ <<-EOS
52
51
  create_table "salaries", id: false, force: :cascade do |t|
53
52
  t.integer "emp_no", limit: 4, default: 0, null: false
54
53
  t.float "salary", limit: 24, null: false
55
54
  t.date "from_date", null: false
56
55
  t.date "to_date", null: false
57
56
  end
58
- RUBY
57
+ EOS
59
58
  }
60
59
 
61
60
  let(:expected_dsl) {
62
- <<-RUBY
61
+ <<-EOS
63
62
  create_table "salaries", id: false, force: :cascade do |t|
64
63
  t.integer "emp_no", limit: 4, null: false
65
64
  t.float "salary", limit: 24, null: false
66
65
  t.date "from_date", null: false
67
66
  t.date "to_date", null: false
68
67
  end
69
- RUBY
68
+ EOS
70
69
  }
71
70
 
72
71
  before { subject.diff(actual_dsl).migrate }
@@ -75,22 +74,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
75
74
  it {
76
75
  delta = subject.diff(expected_dsl)
77
76
  expect(delta.differ?).to be_truthy
78
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
77
+ expect(subject.dump).to match_fuzzy actual_dsl
79
78
  delta.migrate
80
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
79
+ expect(subject.dump).to match_fuzzy expected_dsl
81
80
  }
82
81
  end
83
82
 
84
83
  context 'when default:0 -> default:0' do
85
84
  let(:actual_dsl) {
86
- <<-RUBY
85
+ <<-EOS
87
86
  create_table "salaries", id: false, force: :cascade do |t|
88
87
  t.integer "emp_no", limit: 4, default: 0, null: false
89
88
  t.float "salary", limit: 24, null: false
90
89
  t.date "from_date", null: false
91
90
  t.date "to_date", null: false
92
91
  end
93
- RUBY
92
+ EOS
94
93
  }
95
94
 
96
95
  before { subject.diff(actual_dsl).migrate }
@@ -104,36 +103,36 @@ describe 'Ridgepole::Client#diff -> migrate' do
104
103
 
105
104
  context 'when default:0 -> default:0/null:true' do
106
105
  let(:actual_dsl) {
107
- <<-RUBY
106
+ <<-EOS
108
107
  create_table "salaries", id: false, force: :cascade do |t|
109
108
  t.integer "emp_no", limit: 4, default: 0, null: false
110
109
  t.float "salary", limit: 24, null: false
111
110
  t.date "from_date", null: false
112
111
  t.date "to_date", null: false
113
112
  end
114
- RUBY
113
+ EOS
115
114
  }
116
115
 
117
116
  let(:expected_dsl) {
118
- <<-RUBY
117
+ <<-EOS
119
118
  create_table "salaries", id: false, force: :cascade do |t|
120
119
  t.integer "emp_no", limit: 4, default: 0, null: true
121
120
  t.float "salary", limit: 24, null: false
122
121
  t.date "from_date", null: false
123
122
  t.date "to_date", null: false
124
123
  end
125
- RUBY
124
+ EOS
126
125
  }
127
126
 
128
127
  let(:result_dsl) {
129
- <<-RUBY
128
+ <<-EOS
130
129
  create_table "salaries", id: false, force: :cascade do |t|
131
130
  t.integer "emp_no", limit: 4, default: 0
132
131
  t.float "salary", limit: 24, null: false
133
132
  t.date "from_date", null: false
134
133
  t.date "to_date", null: false
135
134
  end
136
- RUBY
135
+ EOS
137
136
  }
138
137
 
139
138
  before { subject.diff(actual_dsl).migrate }
@@ -142,44 +141,44 @@ describe 'Ridgepole::Client#diff -> migrate' do
142
141
  it {
143
142
  delta = subject.diff(expected_dsl)
144
143
  expect(delta.differ?).to be_truthy
145
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
144
+ expect(subject.dump).to match_fuzzy actual_dsl
146
145
  delta.migrate
147
- expect(subject.dump).to eq result_dsl.strip_heredoc.strip
146
+ expect(subject.dump).to match_fuzzy result_dsl
148
147
  }
149
148
  end
150
149
 
151
150
  context 'when default:0/null:true -> default:nil/null:false' do
152
151
  let(:actual_dsl) {
153
- <<-RUBY
152
+ <<-EOS
154
153
  create_table "salaries", id: false, force: :cascade do |t|
155
154
  t.integer "emp_no", limit: 4, default: 0
156
155
  t.float "salary", limit: 24, null: false
157
156
  t.date "from_date", null: false
158
157
  t.date "to_date", null: false
159
158
  end
160
- RUBY
159
+ EOS
161
160
  }
162
161
 
163
162
  let(:expected_dsl) {
164
- <<-RUBY
163
+ <<-EOS
165
164
  create_table "salaries", id: false, force: :cascade do |t|
166
165
  t.integer "emp_no", limit: 4, null: false
167
166
  t.float "salary", limit: 24, null: false
168
167
  t.date "from_date", null: false
169
168
  t.date "to_date", null: false
170
169
  end
171
- RUBY
170
+ EOS
172
171
  }
173
172
 
174
173
  let(:result_dsl) {
175
- <<-RUBY
174
+ <<-EOS
176
175
  create_table "salaries", id: false, force: :cascade do |t|
177
176
  t.integer "emp_no", limit: 4, default: 0, null: false
178
177
  t.float "salary", limit: 24, null: false
179
178
  t.date "from_date", null: false
180
179
  t.date "to_date", null: false
181
180
  end
182
- RUBY
181
+ EOS
183
182
  }
184
183
 
185
184
  before { subject.diff(actual_dsl).migrate }
@@ -189,16 +188,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
189
188
  expect(Ridgepole::Logger.instance).to receive(:warn).with('[WARNING] Table `salaries`: `default: nil` is ignored when `null: false`. Please apply twice')
190
189
  delta = subject.diff(expected_dsl)
191
190
  expect(delta.differ?).to be_truthy
192
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
191
+ expect(subject.dump).to match_fuzzy actual_dsl
193
192
  delta.migrate
194
- expect(subject.dump).to eq result_dsl.strip_heredoc.strip
193
+ expect(subject.dump).to match_fuzzy result_dsl
195
194
 
196
195
  delta = subject.diff(expected_dsl)
197
196
  expect(delta.differ?).to be_truthy
198
- expect(subject.dump).to eq result_dsl.strip_heredoc.strip
197
+ expect(subject.dump).to match_fuzzy result_dsl
199
198
  delta.migrate
200
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
199
+ expect(subject.dump).to match_fuzzy expected_dsl
201
200
  }
202
201
  end
203
202
  end
204
- end