Skip to content

Commit

Permalink
Fix warning: Using the last argument as keyword parameters is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
vsppedro committed Mar 11, 2021
1 parent e746f2e commit 44afa7e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 35 deletions.
2 changes: 1 addition & 1 deletion spec/support/unit/active_record/create_table.rb
Expand Up @@ -109,7 +109,7 @@ def add_column_to_table(table, column_name, column_specification)
)
end

table.column(column_name, column_type, column_options)
table.column(column_name, column_type, **column_options)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/unit/helpers/model_builder.rb
Expand Up @@ -44,7 +44,7 @@ def create_table(table_name, options = {}, &block)

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
Expand Down
Expand Up @@ -21,7 +21,7 @@

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
Expand All @@ -45,7 +45,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(
**options.merge(
column_type: :integer,
column_options: { limit: 2 },
value: 1,
Expand All @@ -71,7 +71,7 @@ def expect_to_match_on_values(builder, values, &block)

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
Expand Down Expand Up @@ -99,7 +99,7 @@ def validation_matcher_scenario_args

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
Expand Down Expand Up @@ -130,7 +130,7 @@ def validation_matcher_scenario_args

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
Expand Down Expand Up @@ -158,7 +158,7 @@ def validation_matcher_scenario_args

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
Expand Down Expand Up @@ -186,7 +186,7 @@ def validation_matcher_scenario_args

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
Expand All @@ -207,7 +207,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(column_type: :string),
**options.merge(column_type: :string),
&block
)
end
Expand Down Expand Up @@ -798,7 +798,7 @@ def configure_validation_matcher(matcher)

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
Expand Down Expand Up @@ -842,7 +842,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
super(
options.merge(column_options: { null: true }, value: true),
**options.merge(column_options: { null: true }, value: true),
&block
)
end
Expand All @@ -863,13 +863,13 @@ def build_object(**options, &block)
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
Expand All @@ -896,15 +896,15 @@ def validation_matcher_scenario_args
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

context 'against a boolean attribute (designated by false)' do
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

Expand Down Expand Up @@ -1010,7 +1010,7 @@ def define_model_validating_inclusion(
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
Expand Down
Expand Up @@ -714,7 +714,7 @@ def create_child_model_belonging_to_parent(
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)
Expand Down Expand Up @@ -743,7 +743,7 @@ def belonging_to_with_inverse(association, inverse_association)

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
Expand Down Expand Up @@ -1158,14 +1158,14 @@ def having_many_children(options = {})
order = options.delete(:order)
define_association_with_order(model, :has_many, :children, order, options)
else
model.has_many :children, options
model.has_many :children, **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
Expand Down Expand Up @@ -1496,14 +1496,14 @@ def having_one_detail(options = {})
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
Expand Down Expand Up @@ -2126,25 +2126,17 @@ def having_and_belonging_to_many_relatives(_options = {})

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

def define_association_with_conditions(model, macro, name, conditions, _other_options = {})
args = []
options = {}
args << proc { where(conditions) }
args << options
model.__send__(macro, name, *args)
model.__send__(macro, name, proc { where(conditions) }, **{})
end

def define_association_with_order(model, macro, name, order, _other_options = {})
args = []
options = {}
args << proc { order(order) }
args << options
model.__send__(macro, name, *args)
model.__send__(macro, name, proc { order(order) }, **{})
end

def dependent_options
Expand Down
Expand Up @@ -112,7 +112,7 @@ def model(options = {})

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
Expand Down

0 comments on commit 44afa7e

Please sign in to comment.