ridgepole 0.8.6 → 0.8.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +62 -0
  3. data/.rubocop.yml +12 -3
  4. data/README.md +14 -2
  5. data/lib/ridgepole/delta.rb +29 -22
  6. data/lib/ridgepole/diff.rb +12 -0
  7. data/lib/ridgepole/dsl_parser.rb +3 -4
  8. data/lib/ridgepole/dsl_parser/context.rb +6 -3
  9. data/lib/ridgepole/dsl_parser/table_definition.rb +7 -0
  10. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +1 -1
  11. data/lib/ridgepole/external_sql_executer.rb +1 -1
  12. data/lib/ridgepole/version.rb +1 -1
  13. data/ridgepole.gemspec +1 -1
  14. data/spec/dsl_parser/context_spec.rb +16 -0
  15. data/spec/erb_helper.rb +4 -4
  16. data/spec/fixtures/for_require_relative_spec.rb +3 -0
  17. data/spec/mysql/collation/collation_spec.rb +6 -0
  18. data/spec/mysql/diff/diff2_spec.rb +3 -3
  19. data/spec/mysql/diff/diff_spec.rb +3 -3
  20. data/spec/mysql/fk/migrate_create_fk_spec.rb +79 -10
  21. data/spec/mysql/fk/migrate_drop_fk_spec.rb +1 -1
  22. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +2 -2
  23. data/spec/mysql/migrate/migrate_add_column_spec.rb +5 -5
  24. data/spec/mysql/migrate/migrate_change_column3_spec.rb +122 -0
  25. data/spec/mysql/migrate/migrate_change_column_spec.rb +5 -5
  26. data/spec/mysql/migrate/migrate_change_index_spec.rb +9 -9
  27. data/spec/mysql/migrate/migrate_create_index_spec.rb +6 -6
  28. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +7 -7
  29. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +8 -8
  30. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +4 -4
  31. data/spec/mysql/migrate/migrate_drop_column_spec.rb +3 -3
  32. data/spec/mysql/migrate/migrate_drop_index_spec.rb +6 -6
  33. data/spec/mysql/migrate/migrate_rename_column_spec.rb +3 -3
  34. data/spec/mysql/migrate/migrate_script_error_spec.rb +1 -1
  35. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +4 -1
  36. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +1 -1
  37. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +1 -1
  38. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +7 -7
  39. data/spec/postgresql/diff/diff_spec.rb +2 -2
  40. data/spec/postgresql/fk/migrate_create_fk_spec.rb +2 -2
  41. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +1 -1
  42. data/spec/postgresql/migrate/migrate_add_column_spec.rb +5 -5
  43. data/spec/postgresql/migrate/migrate_change_column_spec.rb +4 -4
  44. data/spec/postgresql/migrate/migrate_change_index_spec.rb +9 -9
  45. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +3 -3
  46. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +5 -5
  47. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +1 -1
  48. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +6 -6
  49. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +2 -2
  50. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +1 -1
  51. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +1 -1
  52. data/spec/spec_condition.rb +4 -4
  53. data/spec/spec_helper.rb +2 -1
  54. metadata +11 -7
  55. data/.travis.yml +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e81708c1fcd99a721354e49bdd8281e42657271da21acd80ecbf87e5a6b51890
4
- data.tar.gz: d4d2321cfc763a9f23bd9e3d57e16ef5e07c852653e198286ef9d39ef16275b4
3
+ metadata.gz: 367dff4faf9fd7e94588cdefe290cf13953cf82b9dc5110e91cfd5d4ee2507a3
4
+ data.tar.gz: 20ad65390cd7b12fe97e8fbae409aa5bc0d86a6c73c79a9916bfc55f46f03cb6
5
5
  SHA512:
6
- metadata.gz: 55bf02b0f28ea259810c140697def6312f937e14cfc023be4aa6da75699844fd654b6d519896691ee1ddf7d1e2c60a12630d3820ce7e5e3505f210f400b02726
7
- data.tar.gz: cd121f6363ffb2136a124990c9f373f984a634302d0e8633cfe2f9fc164e0e244eaf0997d52bdd4c3aa618e28b02593f755b8e6485a87dc0b6aba023a3237d45
6
+ metadata.gz: 94039eb4e75e2f0b218275ffec9b8a1b4c28ae5b9c93ad64b584793acbabc1ece9eb8ddde4e6d3097ffc6a9346ef36a6318334048d99c8e85050e0b9ef3088bd
7
+ data.tar.gz: 5e4837104ea5b6b69e42fdcc82e29b71a33835ce8371b959c16f3c00b014047a88b3c01ecba74ab8d6e591fd3357d15019a1dc41c425ff4c10b49fcec6bbdc48
@@ -0,0 +1,62 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby:
14
+ - 2.4
15
+ - 2.5
16
+ - 2.6
17
+ - 2.7
18
+ env:
19
+ - MYSQL56=1
20
+ - MYSQL57=1
21
+ - POSTGRESQL=1
22
+ gemfile:
23
+ - gemfiles/activerecord_5.0.gemfile
24
+ - gemfiles/activerecord_5.1.gemfile
25
+ - gemfiles/activerecord_5.2.gemfile
26
+ - gemfiles/activerecord_6.0.gemfile
27
+ exclude:
28
+ - ruby: 2.4
29
+ gemfile: gemfiles/activerecord_6.0.gemfile
30
+
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - uses: actions/setup-ruby@v1
34
+ with:
35
+ ruby-version: ${{ matrix.ruby }}
36
+ - uses: actions/cache@v2
37
+ with:
38
+ path: gemfiles/vendor/bundle
39
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles('ridgepole.gemspec', '**/Gemfile', '${{ matrix.gemfile }}') }}
40
+ restore-keys: |
41
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-
42
+
43
+ - name: Setup dependencies
44
+ run: |
45
+ for i in {1..60}; do docker-compose up -d && break; sleep 1; done
46
+
47
+ bundle config path vendor/bundle
48
+ bundle install --jobs 4 --retry 3
49
+
50
+ # Wait until database servers start
51
+ function mysql_ping { mysqladmin -u root -h 127.0.0.1 -P 13316 -ppassword ping; }
52
+ function mysql57_ping { mysqladmin -u root -h 127.0.0.1 -P 13317 -ppassword ping; }
53
+ function pg_ping { PGPASSWORD=password pg_isready -U postgres -h 127.0.0.1 -p 15442; }
54
+ for i in {1..60}; do mysql_ping && break; sleep 1; done
55
+ for i in {1..60}; do mysql57_ping && break; sleep 1; done
56
+ for i in {1..60}; do pg_ping && break; sleep 1; done
57
+ env:
58
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
59
+
60
+ - run: ${{ matrix.env }} bundle exec rake
61
+ env:
62
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
@@ -3,6 +3,7 @@ AllCops:
3
3
  - 'gemfiles/**/*'
4
4
  - 'omnibus-ridgepole/**/*'
5
5
  TargetRubyVersion: 2.4
6
+ NewCops: enable
6
7
  Bundler/OrderedGems:
7
8
  Include:
8
9
  - 'Appraisals'
@@ -18,7 +19,7 @@ Metrics/ClassLength:
18
19
  Enabled: false
19
20
  Metrics/CyclomaticComplexity:
20
21
  Enabled: false
21
- Style/LineLength:
22
+ Layout/LineLength:
22
23
  Enabled: false
23
24
  Metrics/MethodLength:
24
25
  Enabled: false
@@ -30,8 +31,6 @@ Style/Documentation:
30
31
  Enabled: false
31
32
  Style/GuardClause:
32
33
  Enabled: false
33
- Style/MethodMissingSuper:
34
- Enabled: false
35
34
  Style/MixinUsage:
36
35
  Exclude:
37
36
  - 'spec/**/*'
@@ -41,3 +40,13 @@ Layout/ClosingHeredocIndentation:
41
40
  Enabled: false
42
41
  Style/NumericPredicate:
43
42
  Enabled: false
43
+ Lint/MissingSuper:
44
+ Enabled: false
45
+ Style/StringConcatenation:
46
+ Enabled: false
47
+ Style/SoleNestedConditional:
48
+ Enabled: false
49
+ Lint/DuplicateBranch:
50
+ Enabled: false
51
+ Style/OptionalBooleanParameter:
52
+ Enabled: false
data/README.md CHANGED
@@ -6,7 +6,7 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
6
6
  (like Chef/Puppet)
7
7
 
8
8
  [![Gem Version](https://badge.fury.io/rb/ridgepole.svg)](http://badge.fury.io/rb/ridgepole)
9
- [![Build Status](https://travis-ci.org/winebarrel/ridgepole.svg?branch=0.8)](https://travis-ci.org/winebarrel/ridgepole)
9
+ [![Build Status](https://github.com/winebarrel/ridgepole/workflows/test/badge.svg?branch=0.8)](https://github.com/winebarrel/ridgepole/actions)
10
10
  [![Coverage Status](https://coveralls.io/repos/github/winebarrel/ridgepole/badge.svg?branch=0.8)](https://coveralls.io/github/winebarrel/ridgepole?branch=0.8)
11
11
 
12
12
  <details><summary>ChangeLog</summary>
@@ -113,6 +113,18 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
113
113
  * Improve warning message on table options ([pull#291](https://github.com/winebarrel/ridgepole/pull/291))
114
114
  * `>= 0.8.6`
115
115
  * Support multiple databases feature ([pull#297](https://github.com/winebarrel/ridgepole/pull/297))
116
+ * `>= 0.8.7`
117
+ * Support `require_relative` ([pull#298](https://github.com/winebarrel/ridgepole/pull/298))
118
+ * `>= 0.8.8`
119
+ * Fix keyword arguments warnings in Ruby 2.7 ([pull#303](https://github.com/winebarrel/ridgepole/pull/303))
120
+ * `>= 0.8.9`
121
+ * Fix unexpected differences on text types and blob types on Rails 6 ([pull#306](https://github.com/winebarrel/ridgepole/pull/306))
122
+ * Fix unexpected warning when a foreign key is added on the primary key ([pull#307](https://github.com/winebarrel/ridgepole/pull/307))
123
+ * `>= 0.8.10`
124
+ * Raise an error if an InnoDB column has a foreign key but no index ([pull#310](https://github.com/winebarrel/ridgepole/pull/310))
125
+ * `>= 0.8.11`
126
+ * Fix FK index check support multiple PK ([pull#315](https://github.com/winebarrel/ridgepole/pull/315))
127
+ * Support t.reference() foreign_key option ([pull#316](https://github.com/winebarrel/ridgepole/pull/316))
116
128
  </details>
117
129
 
118
130
  ## Installation
@@ -191,6 +203,7 @@ Usage: ridgepole [options]
191
203
  --ignore-table-comment
192
204
  --skip-column-comment-change
193
205
  --create-table-with-index
206
+ --allow-pk-change
194
207
  --mysql-dump-auto-increment
195
208
  -r, --require LIBS
196
209
  --log-file LOG_FILE
@@ -307,7 +320,6 @@ end
307
320
  ```
308
321
 
309
322
  ## Collation/Charset
310
- You can use the column collation by passing `--enable-mysql-awesome` ([activerecord-mysql-awesome](https://github.com/kamipo/activerecord-mysql-awesome) is required)
311
323
 
312
324
  ```ruby
313
325
  create_table "articles", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
@@ -246,7 +246,7 @@ create_table(#{table_name.inspect}, #{inspect_options_include_default_proc(optio
246
246
  end
247
247
 
248
248
  buf.puts(<<-RUBY)
249
- end
249
+ end
250
250
  RUBY
251
251
 
252
252
  if !(@options[:create_table_with_index]) && !indices.empty?
@@ -326,7 +326,7 @@ execute "ALTER TABLE #{ActiveRecord::Base.connection.quote_table_name(table_name
326
326
  end
327
327
 
328
328
  def append_change_table(table_name, buf)
329
- buf.puts "change_table(#{table_name.inspect}, {:bulk => true}) do |t|" if @options[:bulk_change]
329
+ buf.puts "change_table(#{table_name.inspect}, bulk: true) do |t|" if @options[:bulk_change]
330
330
  yield
331
331
  buf.puts 'end' if @options[:bulk_change]
332
332
  end
@@ -429,11 +429,11 @@ remove_column(#{table_name.inspect}, #{column_name.inspect})
429
429
 
430
430
  if force_bulk_change || @options[:bulk_change]
431
431
  buf.puts(<<-RUBY)
432
- t.index(#{column_name.inspect}, #{options.inspect})
432
+ t.index(#{column_name.inspect}, **#{options.inspect})
433
433
  RUBY
434
434
  else
435
435
  buf.puts(<<-RUBY)
436
- add_index(#{table_name.inspect}, #{column_name.inspect}, #{options.inspect})
436
+ add_index(#{table_name.inspect}, #{column_name.inspect}, **#{options.inspect})
437
437
  RUBY
438
438
  end
439
439
  end
@@ -441,15 +441,20 @@ add_index(#{table_name.inspect}, #{column_name.inspect}, #{options.inspect})
441
441
  def append_remove_index(table_name, _index_name, attrs, buf)
442
442
  column_name = attrs.fetch(:column_name)
443
443
  options = attrs[:options] || {}
444
- target = options[:name] ? { name: options[:name] } : column_name
444
+ target =
445
+ if options[:name]
446
+ "name: #{options[:name].inspect}"
447
+ else
448
+ column_name.inspect
449
+ end
445
450
 
446
451
  if @options[:bulk_change]
447
452
  buf.puts(<<-RUBY)
448
- t.remove_index(#{target.inspect})
453
+ t.remove_index(#{target})
449
454
  RUBY
450
455
  else
451
456
  buf.puts(<<-RUBY)
452
- remove_index(#{table_name.inspect}, #{target.inspect})
457
+ remove_index(#{table_name.inspect}, #{target})
453
458
  RUBY
454
459
  end
455
460
  end
@@ -469,7 +474,7 @@ remove_index(#{table_name.inspect}, #{target.inspect})
469
474
  attrs_options = attrs[:options] || {}
470
475
 
471
476
  buf.puts(<<-RUBY)
472
- add_foreign_key(#{table_name.inspect}, #{to_table.inspect}, #{attrs_options.inspect})
477
+ add_foreign_key(#{table_name.inspect}, #{to_table.inspect}, **#{attrs_options.inspect})
473
478
  RUBY
474
479
  end
475
480
 
@@ -478,13 +483,13 @@ add_foreign_key(#{table_name.inspect}, #{to_table.inspect}, #{attrs_options.insp
478
483
  fk_name = attrs_options[:name]
479
484
 
480
485
  target = if fk_name
481
- { name: fk_name }
486
+ "name: #{fk_name.inspect}"
482
487
  else
483
- attrs.fetch(:to_table)
488
+ attrs.fetch(:to_table).inspect
484
489
  end
485
490
 
486
491
  buf.puts(<<-RUBY)
487
- remove_foreign_key(#{table_name.inspect}, #{target.inspect})
492
+ remove_foreign_key(#{table_name.inspect}, #{target})
488
493
  RUBY
489
494
  end
490
495
 
@@ -500,17 +505,19 @@ remove_foreign_key(#{table_name.inspect}, #{target.inspect})
500
505
  def inspect_options_include_default_proc(options)
501
506
  options = options.dup
502
507
 
503
- if options[:default].is_a?(Proc)
504
- proc_default = options.delete(:default)
505
- proc_default = ":default=>proc{#{proc_default.call.inspect}}"
506
- options_inspect = options.inspect
507
- options_inspect.sub!(/\}\z/, '')
508
- options_inspect << ', ' if options_inspect !~ /\{\z/
509
- options_inspect << proc_default << '}'
510
- options_inspect
511
- else
512
- options.inspect
513
- end
508
+ kwargs =
509
+ if options[:default].is_a?(Proc)
510
+ proc_default = options.delete(:default)
511
+ proc_default = ":default=>proc{#{proc_default.call.inspect}}"
512
+ options_inspect = options.inspect
513
+ options_inspect.sub!(/\}\z/, '')
514
+ options_inspect << ', ' if options_inspect !~ /\{\z/
515
+ options_inspect << proc_default << '}'
516
+ options_inspect
517
+ else
518
+ options.inspect
519
+ end
520
+ "**#{kwargs}"
514
521
  end
515
522
  end
516
523
  end
@@ -386,6 +386,18 @@ module Ridgepole
386
386
  attrs[:type] = :bigint
387
387
  opts.delete(:limit)
388
388
  end
389
+
390
+ if opts[:size] && (attrs[:type] == :text || attrs[:type] == :blob || attrs[:type] == :binary)
391
+ case opts.delete(:size)
392
+ when :tiny
393
+ attrs[:type] = :blob if attrs[:type] == :binary
394
+ opts[:limit] = 255
395
+ when :medium
396
+ opts[:limit] = 16_777_215
397
+ when :long
398
+ opts[:limit] = 4_294_967_295
399
+ end
400
+ end
389
401
  end
390
402
  end
391
403
 
@@ -37,11 +37,10 @@ module Ridgepole
37
37
  attrs[:foreign_keys].each do |_, foreign_key_attrs|
38
38
  fk_index = foreign_key_attrs[:options][:column] || "#{foreign_key_attrs[:to_table].singularize}_id"
39
39
  next if attrs[:indices]&.any? { |_k, v| v[:column_name].first == fk_index }
40
+ # NOTE: For composite primary keys, the first column of the primary key is used as the foreign key index
41
+ next if Array(attrs[:options][:primary_key]).first == fk_index
40
42
 
41
- Ridgepole::Logger.instance.warn(<<-MSG)
42
- [WARNING] Table `#{table_name}` has a foreign key on `#{fk_index}` column, but doesn't have any indexes on the column.
43
- Although an index will be added automatically by InnoDB, please add an index explicitly for your future operations.
44
- MSG
43
+ raise "The column `#{fk_index}` of the table `#{table_name}` has a foreign key but no index. Although InnoDB creates an index automatically, please add one explicitly in order for ridgepole to manage it."
45
44
  end
46
45
  end
47
46
  end
@@ -3,8 +3,7 @@
3
3
  module Ridgepole
4
4
  class DSLParser
5
5
  class Context
6
- attr_reader :__definition
7
- attr_reader :__execute
6
+ attr_reader :__definition, :__execute
8
7
 
9
8
  def initialize(opts = {})
10
9
  @__working_dir = File.expand_path(opts[:path] ? File.dirname(opts[:path]) : Dir.pwd)
@@ -28,7 +27,7 @@ module Ridgepole
28
27
  table_name = table_name.to_s
29
28
  table_definition = TableDefinition.new(table_name, self)
30
29
 
31
- options[:primary_key] = options[:primary_key].to_s if options[:primary_key]&.is_a?(Symbol)
30
+ options[:primary_key] = options[:primary_key].to_s if options[:primary_key].is_a?(Symbol)
32
31
  if options[:id] && TableDefinition::ALIAS_TYPES.key?(options[:id])
33
32
  type, type_default_opts = TableDefinition::ALIAS_TYPES[options[:id]]
34
33
  options[:id] = type
@@ -104,6 +103,10 @@ module Ridgepole
104
103
  end
105
104
  end
106
105
 
106
+ def require_relative(relative_path)
107
+ require(File.expand_path(relative_path, File.dirname(caller[0])))
108
+ end
109
+
107
110
  def execute(sql, _name = nil, &cond)
108
111
  @__execute << {
109
112
  sql: sql,
@@ -131,6 +131,7 @@ module Ridgepole
131
131
  polymorphic_options.merge!(options.slice(:null, :first, :after))
132
132
  index_options = options.key?(:index) ? options.delete(:index) : true
133
133
  type = options.delete(:type) || DEFAULT_PRIMARY_KEY_TYPE
134
+ foreign_key_options = options.delete(:foreign_key)
134
135
 
135
136
  args.each do |col|
136
137
  column("#{col}_id", type, options)
@@ -139,6 +140,12 @@ module Ridgepole
139
140
  columns = polymorphic ? ["#{col}_type", "#{col}_id"] : ["#{col}_id"]
140
141
  index(columns, index_options.is_a?(Hash) ? index_options : {})
141
142
  end
143
+ if foreign_key_options # rubocop:disable Style/Next
144
+ fk_opts = foreign_key_options.is_a?(Hash) ? foreign_key_options.dup : {}
145
+ fk_opts.update(column: "#{col}_id") if col.to_s.singularize != col.to_s
146
+ to_table = fk_opts.delete(:to_table) || col
147
+ @base.add_foreign_key(@table_name, to_table, fk_opts)
148
+ end
142
149
  end
143
150
  end
144
151
  alias belongs_to references
@@ -7,7 +7,7 @@ module Ridgepole
7
7
  module AbstractMysqlAdapter
8
8
  module UseAlterIndex
9
9
  def add_index(table_name, column_name, options = {})
10
- index_name, index_type, index_columns, index_options, _index_algorithm, index_using = add_index_options(table_name, column_name, options)
10
+ index_name, index_type, index_columns, index_options, _index_algorithm, index_using = add_index_options(table_name, column_name, **options)
11
11
 
12
12
  # cannot specify index_algorithm
13
13
  execute "ALTER TABLE #{quote_table_name(table_name)} ADD #{index_type} INDEX #{quote_column_name(index_name)} #{index_using} (#{index_columns})#{index_options}"
@@ -41,7 +41,7 @@ module Ridgepole
41
41
  end
42
42
  end
43
43
  end
44
- rescue EOFError # rubocop:disable Lint/SuppressedException
44
+ rescue EOFError
45
45
  # nothing to do
46
46
  end
47
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '0.8.6'
4
+ VERSION = '0.8.11'
5
5
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.required_ruby_version = Gem::Requirement.new('>= 2.2.7')
22
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.2.7') # rubocop:disable Gemspec/RequiredRubyVersion
23
23
 
24
24
  spec.add_dependency 'activerecord', '>= 5.0.1', '< 6.1'
25
25
  spec.add_dependency 'diffy'
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Ridgepole::DSLParser::Context do
4
+ describe '#require_relative' do
5
+ subject { context.require_relative(relative_path) }
6
+
7
+ let!(:context) do
8
+ Ridgepole::DSLParser::Context.new
9
+ end
10
+ let!(:relative_path) do
11
+ '../fixtures/for_require_relative_spec.rb'
12
+ end
13
+
14
+ it { is_expected.to be_truthy }
15
+ end
16
+ end
@@ -18,9 +18,9 @@ ERBh.define_method(:cond) do |conds, m, e = nil|
18
18
  m
19
19
  else
20
20
  e || (begin
21
- m.class.new
22
- rescue StandardError
23
- nil
24
- end)
21
+ m.class.new
22
+ rescue StandardError
23
+ nil
24
+ end)
25
25
  end
26
26
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ 'This file is used by dsl_parser/context_spec.'
@@ -138,6 +138,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
138
138
  opts = ['--dump-without-table-options']
139
139
  out, status = run_ridgepole('--diff', "'#{JSON.dump(conn_spec)}'", f.path, *opts)
140
140
 
141
+ # v6.0.3 is the oldest version that doesn't produce any kwargs warnings with Ruby 2.7
142
+ if condition('< 6.0.3')
143
+ # https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
144
+ out = out.lines.grep_v(/: warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z/).join
145
+ end
146
+
141
147
  expect(out).to be_empty
142
148
  expect(status.success?).to be_truthy
143
149
  end
@@ -175,10 +175,10 @@ describe 'Ridgepole::Client.diff' do
175
175
  delta = subject.diff(actual_dsl, expected_dsl)
176
176
  expect(delta.differ?).to be_truthy
177
177
  expect(delta.script).to match_ruby erbh(<<-ERB)
178
- change_column("employee_clubs", "club_id", :integer, <%= {:unsigned=>false, :null=>true, :default=>nil} + cond('>= 5.1', comment: nil) %>)
178
+ change_column("employee_clubs", "club_id", :integer, **<%= {:unsigned=>false, :null=>true, :default=>nil} + cond('>= 5.1', comment: nil) %>)
179
179
 
180
- change_column("employees", "last_name", :string, <%= {:limit=>20, :default=>"XXX", :unsigned=>false} + cond('>= 5.1', comment: nil) %>)
181
- change_column("employees", "gender", :string, <%= {:limit=>2, :null=>false, :default=>nil, :unsigned=>false} + cond('>= 5.1', comment: nil) %>)
180
+ change_column("employees", "last_name", :string, **<%= {:limit=>20, :default=>"XXX", :unsigned=>false} + cond('>= 5.1', comment: nil) %>)
181
+ change_column("employees", "gender", :string, **<%= {:limit=>2, :null=>false, :default=>nil, :unsigned=>false} + cond('>= 5.1', comment: nil) %>)
182
182
  ERB
183
183
  }
184
184