diff --git a/spec/support/unit/active_record/create_table.rb b/spec/support/unit/active_record/create_table.rb index 3b46df61e..208207675 100644 --- a/spec/support/unit/active_record/create_table.rb +++ b/spec/support/unit/active_record/create_table.rb @@ -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 diff --git a/spec/support/unit/helpers/model_builder.rb b/spec/support/unit/helpers/model_builder.rb index 4a7fae830..dffb637aa 100644 --- a/spec/support/unit/helpers/model_builder.rb +++ b/spec/support/unit/helpers/model_builder.rb @@ -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 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 ad01d142c..80599530c 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 @@ 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 @@ 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, @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -896,7 +896,7 @@ 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 @@ -904,7 +904,7 @@ def build_object(**options, &block) 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 @@ 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 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 dbb7fdfb4..d88297fa9 100644 --- a/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 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 8d56315f6..47ae006ee 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 @@ 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