338 lines
13 KiB
Diff
338 lines
13 KiB
Diff
From 8a4efb6a6da140a001144fffc7042f15f601c991 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
|
|
Date: Tue, 9 Feb 2021 16:09:45 +0100
|
|
Subject: [PATCH] Fix keyword arguments for Ruby 3.0 compatibility.
|
|
|
|
---
|
|
.../unit/active_record/create_table.rb | 2 +-
|
|
spec/support/unit/helpers/model_builder.rb | 24 +++++++--------
|
|
.../validate_inclusion_of_matcher_spec.rb | 30 +++++++++----------
|
|
.../active_record/association_matcher_spec.rb | 20 ++++++-------
|
|
.../have_db_column_matcher_spec.rb | 2 +-
|
|
.../have_db_index_matcher_spec.rb | 2 +-
|
|
6 files changed, 40 insertions(+), 40 deletions(-)
|
|
|
|
diff --git a/spec/support/unit/active_record/create_table.rb b/spec/support/unit/active_record/create_table.rb
|
|
index a80ac444..e12a409c 100644
|
|
--- a/spec/support/unit/active_record/create_table.rb
|
|
+++ b/spec/support/unit/active_record/create_table.rb
|
|
@@ -125,7 +125,7 @@ module UnitTests
|
|
)
|
|
end
|
|
|
|
- table.column(column_name, column_type, column_options)
|
|
+ table.column(column_name, column_type, **column_options)
|
|
end
|
|
end
|
|
end
|
|
diff --git a/spec/support/unit/helpers/model_builder.rb b/spec/support/unit/helpers/model_builder.rb
|
|
index 4a7fae83..036ae9a0 100644
|
|
--- a/spec/support/unit/helpers/model_builder.rb
|
|
+++ b/spec/support/unit/helpers/model_builder.rb
|
|
@@ -2,24 +2,24 @@ require_relative 'class_builder'
|
|
|
|
module UnitTests
|
|
module ModelBuilder
|
|
- def create_table(*args, &block)
|
|
- ModelBuilder.create_table(*args, &block)
|
|
+ def create_table(*args, **options, &block)
|
|
+ ModelBuilder.create_table(*args, **options, &block)
|
|
end
|
|
|
|
- def define_model(*args, &block)
|
|
- ModelBuilder.define_model(*args, &block)
|
|
+ def define_model(*args, **options, &block)
|
|
+ ModelBuilder.define_model(*args, **options, &block)
|
|
end
|
|
|
|
- def define_model_instance(*args, &block)
|
|
- define_model(*args, &block).new
|
|
+ def define_model_instance(*args, **options, &block)
|
|
+ define_model(*args, **options, &block).new
|
|
end
|
|
|
|
- def define_model_class(*args, &block)
|
|
- ModelBuilder.define_model_class(*args, &block)
|
|
+ def define_model_class(*args, **options, &block)
|
|
+ ModelBuilder.define_model_class(*args, **options, &block)
|
|
end
|
|
|
|
- def define_active_model_class(*args, &block)
|
|
- ModelBuilder.define_active_model_class(*args, &block)
|
|
+ def define_active_model_class(*args, **options, &block)
|
|
+ ModelBuilder.define_active_model_class(*args, **options, &block)
|
|
end
|
|
|
|
class << self
|
|
@@ -38,13 +38,13 @@ module UnitTests
|
|
defined_models.clear
|
|
end
|
|
|
|
- def create_table(table_name, options = {}, &block)
|
|
+ def create_table(table_name, **options, &block)
|
|
connection =
|
|
options.delete(:connection) || DevelopmentRecord.connection
|
|
|
|
begin
|
|
connection.execute("DROP TABLE IF EXISTS #{table_name}")
|
|
- connection.create_table(table_name, options, &block)
|
|
+ connection.create_table(table_name, **options, &block)
|
|
created_tables << table_name
|
|
connection
|
|
rescue StandardError => e
|
|
diff --git a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
|
|
index 733d28ee..811ff456 100644
|
|
--- a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
|
|
+++ b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
|
|
@@ -21,7 +21,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
def build_object(**options, &block)
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :integer, value: 1),
|
|
+ **options.merge(column_type: :integer, value: 1),
|
|
&block
|
|
)
|
|
end
|
|
@@ -45,7 +45,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
def build_object(**options, &block)
|
|
build_object_with_generic_attribute(
|
|
- options.merge(
|
|
+ **options.merge(
|
|
column_type: :integer,
|
|
column_options: { limit: 2 },
|
|
value: 1,
|
|
@@ -71,7 +71,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
def build_object(**options, &block)
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :float, value: 1.0),
|
|
+ **options.merge(column_type: :float, value: 1.0),
|
|
&block
|
|
)
|
|
end
|
|
@@ -99,7 +99,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
def build_object(**options, &block)
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :decimal, value: BigDecimal('1.0')),
|
|
+ **options.merge(column_type: :decimal, value: BigDecimal('1.0')),
|
|
&block
|
|
)
|
|
end
|
|
@@ -130,7 +130,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
define_method :build_object do |options = {}, &block|
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :date, value: today),
|
|
+ **options.merge(column_type: :date, value: today),
|
|
&block
|
|
)
|
|
end
|
|
@@ -158,7 +158,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
define_method :build_object do |options = {}, &block|
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :datetime, value: now),
|
|
+ **options.merge(column_type: :datetime, value: now),
|
|
&block
|
|
)
|
|
end
|
|
@@ -186,7 +186,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
define_method :build_object do |options = {}, &block|
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :time, value: default_time),
|
|
+ **options.merge(column_type: :time, value: default_time),
|
|
&block
|
|
)
|
|
end
|
|
@@ -207,7 +207,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
def build_object(**options, &block)
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :string),
|
|
+ **options.merge(column_type: :string),
|
|
&block
|
|
)
|
|
end
|
|
@@ -798,7 +798,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
define_method :build_object do |options = {}, &block|
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :timestamp, value: now),
|
|
+ **options.merge(column_type: :timestamp, value: now),
|
|
&block
|
|
)
|
|
end
|
|
@@ -842,7 +842,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
|
|
def build_object(**options, &block)
|
|
super(
|
|
- options.merge(column_options: { null: true }, value: true),
|
|
+ **options.merge(column_options: { null: true }, value: true),
|
|
&block
|
|
)
|
|
end
|
|
@@ -863,13 +863,13 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
end
|
|
|
|
def build_object(**options, &block)
|
|
- super(options.merge(column_options: { null: false }), &block)
|
|
+ super(**options.merge(column_options: { null: false }), &block)
|
|
end
|
|
end
|
|
|
|
def build_object(**options, &block)
|
|
build_object_with_generic_attribute(
|
|
- options.merge(column_type: :boolean),
|
|
+ **options.merge(column_type: :boolean),
|
|
&block
|
|
)
|
|
end
|
|
@@ -896,7 +896,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
include_context 'against a boolean attribute for true and false'
|
|
|
|
def build_object(**options, &block)
|
|
- build_object_with_generic_attribute(options.merge(value: true), &block)
|
|
+ build_object_with_generic_attribute(**options.merge(value: true), &block)
|
|
end
|
|
end
|
|
|
|
@@ -904,7 +904,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
include_context 'against a boolean attribute for true and false'
|
|
|
|
def build_object(**options, &block)
|
|
- build_object_with_generic_attribute(options.merge(value: false), &block)
|
|
+ build_object_with_generic_attribute(**options.merge(value: false), &block)
|
|
end
|
|
end
|
|
|
|
@@ -1010,7 +1010,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|
column_options: column_options,
|
|
}.compact
|
|
|
|
- define_simple_model(model_options) do |model|
|
|
+ define_simple_model(**model_options) do |model|
|
|
if validation_options
|
|
model.validates_inclusion_of(attribute_name, validation_options)
|
|
end
|
|
diff --git a/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb b/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb
|
|
index 1136fdf6..2ad3c1d1 100644
|
|
--- a/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb
|
|
+++ b/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb
|
|
@@ -809,10 +809,10 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
|
|
parent_options = {},
|
|
&block
|
|
)
|
|
- define_model(:parent, parent_options)
|
|
+ define_model(:parent, **parent_options)
|
|
|
|
define_model :child, parent_id: :integer do
|
|
- belongs_to :parent, options
|
|
+ belongs_to :parent, **options
|
|
|
|
if block
|
|
class_eval(&block)
|
|
@@ -841,7 +841,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
|
|
|
|
def belonging_to_non_existent_class(model_name, assoc_name, options = {})
|
|
define_model model_name, "#{assoc_name}_id" => :integer do
|
|
- belongs_to assoc_name, options
|
|
+ belongs_to assoc_name, **options
|
|
end.new
|
|
end
|
|
end
|
|
@@ -1256,14 +1256,14 @@ Expected Parent to have a has_many association called children through conceptio
|
|
order = options.delete(:order)
|
|
define_association_with_order(model, :has_many, :children, order, options)
|
|
else
|
|
- model.has_many :children, options
|
|
+ model.has_many :children, nil, **options
|
|
end
|
|
end.new
|
|
end
|
|
|
|
def having_many_non_existent_class(model_name, assoc_name, options = {})
|
|
define_model model_name do
|
|
- has_many assoc_name, options
|
|
+ has_many assoc_name, **options
|
|
end.new
|
|
end
|
|
end
|
|
@@ -1596,14 +1596,14 @@ Expected Parent to have a has_many association called children through conceptio
|
|
order = options.delete(:order)
|
|
define_association_with_order(model, :has_one, :detail, order, options)
|
|
else
|
|
- model.has_one :detail, options
|
|
+ model.has_one :detail, **options
|
|
end
|
|
end.new
|
|
end
|
|
|
|
def having_one_non_existent(model_name, assoc_name, options = {})
|
|
define_model model_name do
|
|
- has_one assoc_name, options
|
|
+ has_one assoc_name, **options
|
|
end.new
|
|
end
|
|
end
|
|
@@ -2226,7 +2226,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
|
|
|
def having_and_belonging_to_many_non_existent_class(model_name, assoc_name, options = {})
|
|
define_model model_name do
|
|
- has_and_belongs_to_many assoc_name, options
|
|
+ has_and_belongs_to_many assoc_name, **options
|
|
end.new
|
|
end
|
|
end
|
|
@@ -2238,8 +2238,8 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
|
args << proc { where(conditions) }
|
|
else
|
|
options[:conditions] = conditions
|
|
+ args << options
|
|
end
|
|
- args << options
|
|
model.__send__(macro, name, *args)
|
|
end
|
|
|
|
@@ -2250,8 +2250,8 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
|
args << proc { order(order) }
|
|
else
|
|
options[:order] = order
|
|
+ args << options
|
|
end
|
|
- args << options
|
|
model.__send__(macro, name, *args)
|
|
end
|
|
|
|
diff --git a/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb b/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
|
|
index 8d56315f..47ae006e 100644
|
|
--- a/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
|
|
+++ b/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
|
|
@@ -112,7 +112,7 @@ describe Shoulda::Matchers::ActiveRecord::HaveDbColumnMatcher, type: :model do
|
|
|
|
def with_table(column_name, column_type, options)
|
|
create_table 'employees' do |table|
|
|
- table.__send__(column_type, column_name, options)
|
|
+ table.__send__(column_type, column_name, **options)
|
|
end
|
|
define_model_class('Employee').new
|
|
end
|
|
diff --git a/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb b/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
|
|
index 7a0ffdea..54fe4593 100644
|
|
--- a/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
|
|
+++ b/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
|
|
@@ -494,7 +494,7 @@ does not.
|
|
columns,
|
|
parent_class: parent_class,
|
|
customize_table: -> (table) {
|
|
- table.index(column_name_or_names, index_options)
|
|
+ table.index(column_name_or_names, **index_options)
|
|
},
|
|
)
|
|
model.new
|
|
--
|
|
2.30.0
|
|
|