From 12a0fa85805c4bc0fbb869e3646f62a7820c1dd0 Mon Sep 17 00:00:00 2001 From: lyn1001 Date: Thu, 3 Mar 2022 17:02:21 +0800 Subject: [PATCH] fix build error (cherry picked from commit 1a218eab759e825f9253a9d5d4b181c3771dbe54) --- Add-minimal-support-For-rails-6.patch | 255 ++++++++++++++++++ ...-as-keyword-parameters-is-deprecated.patch | 253 +++++++++++++++++ Handle-argument-delegation-for-ruby-3.patch | 12 + fix-bigdecimal-deprecated.patch | 76 ++++++ fix-build-error.patch | 12 + fix-ruby-2.7-warning.patch | 12 + rubygem-shoulda-matchers.spec | 25 +- 7 files changed, 644 insertions(+), 1 deletion(-) create mode 100644 Add-minimal-support-For-rails-6.patch create mode 100644 Fix-warning-Using-the-last-argument-as-keyword-parameters-is-deprecated.patch create mode 100644 Handle-argument-delegation-for-ruby-3.patch create mode 100644 fix-bigdecimal-deprecated.patch create mode 100644 fix-build-error.patch create mode 100644 fix-ruby-2.7-warning.patch diff --git a/Add-minimal-support-For-rails-6.patch b/Add-minimal-support-For-rails-6.patch new file mode 100644 index 0000000..e8d3608 --- /dev/null +++ b/Add-minimal-support-For-rails-6.patch @@ -0,0 +1,255 @@ +diff -Nur a/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +--- a/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb 2022-03-02 17:38:38.274324841 +0800 ++++ b/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb 2022-03-02 17:48:15.220014811 +0800 +@@ -562,7 +562,8 @@ + + def has_been_qualified? + @submatchers.any? do |submatcher| +- submatcher.class.parent == NumericalityMatchers ++ Shoulda::Matchers::RailsShim.parent_of(submatcher.class) == ++ NumericalityMatchers + end + end + +diff -Nur a/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +--- a/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb 2022-03-02 17:38:38.274324841 +0800 ++++ b/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb 2022-03-02 17:48:15.220014811 +0800 +@@ -134,9 +134,8 @@ + private + + def secure_password_being_validated? +- defined?(::ActiveModel::SecurePassword) && +- @subject.class.ancestors.include?(::ActiveModel::SecurePassword::InstanceMethodsOnActivation) && +- @attribute == :password ++ Shoulda::Matchers::RailsShim.digestible_attributes_in(@subject). ++ include?(@attribute) + end + + def disallows_and_double_checks_value_of!(value, message) +diff -Nur a/lib/shoulda/matchers/active_record/association_matcher.rb b/lib/shoulda/matchers/active_record/association_matcher.rb +--- a/lib/shoulda/matchers/active_record/association_matcher.rb 2022-03-02 17:38:38.278324908 +0800 ++++ b/lib/shoulda/matchers/active_record/association_matcher.rb 2022-03-02 17:57:16.205124877 +0800 +@@ -1182,13 +1182,11 @@ + def class_has_foreign_key?(klass) + if options.key?(:foreign_key) + option_verifier.correct_for_string?(:foreign_key, options[:foreign_key]) ++ elsif column_names_for(klass).include?(foreign_key) ++ true + else +- if klass.column_names.include?(foreign_key) +- true +- else +- @missing = "#{klass} does not have a #{foreign_key} foreign key." +- false +- end ++ @missing = "#{klass} does not have a #{foreign_key} foreign key." ++ false + end + end + +@@ -1226,6 +1224,11 @@ + def submatchers_match? + failing_submatchers.empty? + end ++ def column_names_for(klass) ++ klass.column_names ++ rescue ::ActiveRecord::StatementInvalid ++ [] ++ end + end + end + end +diff -Nur a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +--- a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb 2022-03-02 17:38:38.278324908 +0800 ++++ b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb 2022-03-02 17:48:15.224014878 +0800 +@@ -502,10 +502,11 @@ + end + + def ensure_secure_password_set(instance) +- if has_secure_password? +- instance.password = "password" +- instance.password_confirmation = "password" +- end ++ Shoulda::Matchers::RailsShim.digestible_attributes_in(instance). ++ each do |attribute| ++ instance.send("#{attribute}=", 'password') ++ instance.send("#{attribute}_confirmation=", 'password') ++ end + end + + def update_existing_record!(value) +@@ -529,9 +530,7 @@ + end + + def has_secure_password? +- model.ancestors.map(&:to_s).include?( +- 'ActiveModel::SecurePassword::InstanceMethodsOnActivation' +- ) ++ Shoulda::Matchers::RailsShim.has_secure_password?(subject, @attribute) + end + + def build_new_record +diff -Nur a/lib/shoulda/matchers/rails_shim.rb b/lib/shoulda/matchers/rails_shim.rb +--- a/lib/shoulda/matchers/rails_shim.rb 2022-03-02 17:38:38.274324841 +0800 ++++ b/lib/shoulda/matchers/rails_shim.rb 2022-03-02 17:48:15.224014878 +0800 +@@ -107,6 +107,43 @@ + end + end + ++ def parent_of(mod) ++ if mod.respond_to?(:module_parent) ++ mod.module_parent ++ else ++ mod.parent ++ end ++ end ++ ++ def has_secure_password?(record, attribute_name) ++ if secure_password_module ++ attribute_name == :password && ++ record.class.ancestors.include?(secure_password_module) ++ else ++ record.respond_to?("authenticate_#{attribute_name}") ++ end ++ end ++ ++ def digestible_attributes_in(record) ++ record.methods.inject([]) do |array, method_name| ++ match = method_name.to_s.match( ++ /\A(\w+)_(?:confirmation|digest)=\Z/, ++ ) ++ ++ if match ++ array.concat([match[1].to_sym]) ++ else ++ array ++ end ++ end ++ end ++ ++ def secure_password_module ++ ::ActiveModel::SecurePassword::InstanceMethodsOnActivation ++ rescue NameError ++ nil ++ end ++ + private + + def simply_generate_validation_message( +diff -Nur a/spec/support/unit/helpers/class_builder.rb b/spec/support/unit/helpers/class_builder.rb +--- a/spec/support/unit/helpers/class_builder.rb 2022-03-02 17:38:38.270324774 +0800 ++++ b/spec/support/unit/helpers/class_builder.rb 2022-03-02 17:48:15.224014878 +0800 +@@ -18,18 +18,15 @@ + end + + def reset +- remove_defined_classes ++ remove_defined_modules ++ defined_modules.clear + end + + def define_module(module_name, &block) + module_name = module_name.to_s.camelize ++ namespace, name_without_namespace = parse_constant_name(module_name) + +- namespace, name_without_namespace = +- ClassBuilder.parse_constant_name(module_name) +- +- if namespace.const_defined?(name_without_namespace, false) +- namespace.__send__(:remove_const, name_without_namespace) +- end ++ remove_defined_module(module_name) + + eval <<-RUBY + module #{namespace}::#{name_without_namespace} +@@ -38,6 +35,7 @@ + + namespace.const_get(name_without_namespace).tap do |constant| + constant.unloadable ++ @_defined_modules = defined_modules | [constant] + + if block + constant.module_eval(&block) +@@ -47,13 +45,9 @@ + + def define_class(class_name, parent_class = Object, &block) + class_name = class_name.to_s.camelize ++ namespace, name_without_namespace = parse_constant_name(class_name) + +- namespace, name_without_namespace = +- ClassBuilder.parse_constant_name(class_name) +- +- if namespace.const_defined?(name_without_namespace, false) +- namespace.__send__(:remove_const, name_without_namespace) +- end ++ remove_defined_module(class_name) + + eval <<-RUBY + class #{namespace}::#{name_without_namespace} < ::#{parent_class} +@@ -62,6 +56,7 @@ + + namespace.const_get(name_without_namespace).tap do |constant| + constant.unloadable ++ @_defined_modules = defined_modules | [constant] + + if block + if block.arity == 0 +@@ -82,8 +77,21 @@ + + private + +- def remove_defined_classes +- ::ActiveSupport::Dependencies.clear ++ def remove_defined_modules ++ defined_modules.reverse_each { |mod| remove_defined_module(mod.name) } ++ ActiveSupport::Dependencies.clear ++ end ++ ++ def remove_defined_module(module_name) ++ namespace, name_without_namespace = parse_constant_name(module_name) ++ ++ if namespace.const_defined?(name_without_namespace, false) ++ namespace.__send__(:remove_const, name_without_namespace) ++ end ++ end ++ ++ def defined_modules ++ @_defined_modules ||= [] + end + end + end +diff -Nur a/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb +--- a/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb 2022-03-02 17:38:38.262324640 +0800 ++++ b/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb 2022-03-02 18:04:41.336620792 +0800 +@@ -1,20 +1,18 @@ + require 'unit_spec_helper' + + describe Shoulda::Matchers::ActiveModel::HaveSecurePasswordMatcher, type: :model do +- if active_model_3_1? +- it 'matches when the subject configures has_secure_password with default options' do +- working_model = define_model(:example, password_digest: :string) { has_secure_password } +- expect(working_model.new).to have_secure_password +- end ++ it 'matches when the subject configures has_secure_password with default options' do ++ working_model = define_model(:example, password_digest: :string) { has_secure_password } ++ expect(working_model.new).to have_secure_password ++ end + +- it 'does not match when the subject does not authenticate a password' do +- no_secure_password = define_model(:example) +- expect(no_secure_password.new).not_to have_secure_password +- end ++ it 'does not match when the subject does not authenticate a password' do ++ no_secure_password = define_model(:example) ++ expect(no_secure_password.new).not_to have_secure_password ++ end + +- it 'does not match when the subject is missing the password_digest attribute' do +- no_digest_column = define_model(:example) { has_secure_password } +- expect(no_digest_column.new).not_to have_secure_password +- end ++ it 'does not match when the subject is missing the password_digest attribute' do ++ no_digest_column = define_model(:example) { has_secure_password } ++ expect(no_digest_column.new).not_to have_secure_password + end + end diff --git a/Fix-warning-Using-the-last-argument-as-keyword-parameters-is-deprecated.patch b/Fix-warning-Using-the-last-argument-as-keyword-parameters-is-deprecated.patch new file mode 100644 index 0000000..2765e20 --- /dev/null +++ b/Fix-warning-Using-the-last-argument-as-keyword-parameters-is-deprecated.patch @@ -0,0 +1,253 @@ +diff -Nur a/spec/support/unit/active_record/create_table.rb b/spec/support/unit/active_record/create_table.rb +--- a/spec/support/unit/active_record/create_table.rb 2022-03-02 15:43:54.402107119 +0800 ++++ b/spec/support/unit/active_record/create_table.rb 2022-03-02 15:47:54.230150787 +0800 +@@ -47,7 +47,7 @@ + column_options = {} + end + +- table.column(column_name, column_type, column_options) ++ table.column(column_name, column_type, **column_options) + end + end + end +diff -Nur a/spec/support/unit/helpers/model_builder.rb b/spec/support/unit/helpers/model_builder.rb +--- a/spec/support/unit/helpers/model_builder.rb 2022-03-02 15:43:54.410107254 +0800 ++++ b/spec/support/unit/helpers/model_builder.rb 2022-03-02 15:47:54.230150787 +0800 +@@ -39,7 +39,7 @@ + + 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 Exception => e +diff -Nur 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 +--- a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb 2022-03-02 15:43:54.634111031 +0800 ++++ b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb 2022-03-02 15:55:07.113449499 +0800 +@@ -40,7 +40,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 +@@ -64,7 +64,7 @@ + + def build_object(options = {}, &block) + build_object_with_generic_attribute( +- options.merge( ++ **options.merge( + column_type: :integer, + column_options: { limit: 2 }, + value: 1 +@@ -90,7 +90,7 @@ + + 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 +@@ -118,7 +118,7 @@ + + 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 +@@ -149,7 +149,7 @@ + + 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 +@@ -177,7 +177,7 @@ + + 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 +@@ -204,7 +204,7 @@ + + 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 +@@ -225,7 +225,7 @@ + + def build_object(options = {}, &block) + build_object_with_generic_attribute( +- options.merge(column_type: :string), ++ **options.merge(column_type: :string), + &block + ) + end +@@ -731,7 +731,7 @@ + + 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 +@@ -772,7 +772,7 @@ + end + + def build_object(options = {}, &block) +- super(options.merge(column_options: { null: true }, value: true)) ++ super(**options.merge(column_options: { null: true }, value: true)) + end + end + +@@ -792,13 +792,13 @@ + end + + def build_object(options = {}, &block) +- super(options.merge(column_options: { null: false })) ++ super(**options.merge(column_options: { null: false })) + end + end + + def build_object(options = {}, &block) + build_object_with_generic_attribute( +- options.merge(column_type: :boolean), ++ **options.merge(column_type: :boolean), + &block + ) + end +@@ -820,7 +820,7 @@ + include_context 'against a boolean attribute for true and false' + + def build_object(options = {}, &block) +- build_object_with_generic_attribute(options.merge(value: true)) ++ build_object_with_generic_attribute(**options.merge(value: true)) + end + end + +@@ -828,7 +828,7 @@ + include_context 'against a boolean attribute for true and false' + + def build_object(options = {}, &block) +- build_object_with_generic_attribute(options.merge(value: false)) ++ build_object_with_generic_attribute(**options.merge(value: false)) + end + end + +diff -Nur a/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb b/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +--- a/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb 2022-03-02 15:43:54.630110963 +0800 ++++ b/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb 2022-03-02 15:59:12.837592578 +0800 +@@ -282,13 +282,13 @@ + def belonging_to_parent(options = {}) + define_model :parent + define_model :child, parent_id: :integer do +- belongs_to :parent, options ++ belongs_to :parent, **options + end.new + end + + 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 +@@ -575,14 +575,14 @@ + 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 +@@ -833,14 +833,14 @@ + 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 +@@ -1202,33 +1202,17 @@ + + 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 = {} +- if active_record_supports_relations? +- args << proc { where(conditions) } +- else +- options[:conditions] = conditions +- end +- 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 = {} +- if active_record_supports_relations? +- args << proc { order(order) } +- else +- options[:order] = order +- end +- args << options +- model.__send__(macro, name, *args) ++ model.__send__(macro, name, proc { order(order) }, **{}) + end + + def dependent_options +diff -Nur 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 +--- a/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb 2022-03-02 15:43:54.434107659 +0800 ++++ b/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb 2022-03-02 15:47:54.230150787 +0800 +@@ -104,7 +104,7 @@ + + 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/Handle-argument-delegation-for-ruby-3.patch b/Handle-argument-delegation-for-ruby-3.patch new file mode 100644 index 0000000..fd8dd3c --- /dev/null +++ b/Handle-argument-delegation-for-ruby-3.patch @@ -0,0 +1,12 @@ +diff -Nur a/lib/shoulda/matchers/rails_shim.rb b/lib/shoulda/matchers/rails_shim.rb +--- a/lib/shoulda/matchers/rails_shim.rb 2022-03-02 16:34:47.793626953 +0800 ++++ b/lib/shoulda/matchers/rails_shim.rb 2022-03-02 16:38:09.209032206 +0800 +@@ -61,7 +61,7 @@ + request_params + end + +- context.__send__(verb, action, params) ++ context.__send__(verb, action,**params) + end + + def serialized_attributes_for(model) diff --git a/fix-bigdecimal-deprecated.patch b/fix-bigdecimal-deprecated.patch new file mode 100644 index 0000000..312bb6f --- /dev/null +++ b/fix-bigdecimal-deprecated.patch @@ -0,0 +1,76 @@ +From 0c07bfb039b0fe9f9863e885ee3885e48f3b39d9 Mon Sep 17 00:00:00 2001 +From: Teo Ljungberg +Date: Wed, 27 Dec 2017 17:20:02 +0100 +Subject: [PATCH] Use `BigDecimal()` over `BigDecimal.new` + +As the latter is deprecated since: ruby/bigdecimal@5337373 +--- + .../active_model/validate_absence_of_matcher.rb | 2 +- + .../active_model/validate_inclusion_of_matcher.rb | 2 +- + .../validate_inclusion_of_matcher_spec.rb | 12 ++++++------ + 3 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +index 1c33816c0..f663f55e8 100644 +--- a/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb ++++ b/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +@@ -105,7 +105,7 @@ def value + else + case column_type + when :integer, :float then 1 +- when :decimal then BigDecimal.new(1, 0) ++ when :decimal then BigDecimal(1, 0) + when :datetime, :time, :timestamp then Time.now + when :date then Date.new + when :binary then '0' +diff --git a/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +index 717eecc95..4b96be052 100644 +--- a/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb ++++ b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +@@ -270,7 +270,7 @@ def validate_inclusion_of(attr) + class ValidateInclusionOfMatcher < ValidationMatcher + ARBITRARY_OUTSIDE_STRING = 'shoulda-matchers test string' + ARBITRARY_OUTSIDE_INTEGER = 123456789 +- ARBITRARY_OUTSIDE_DECIMAL = BigDecimal.new('0.123456789') ++ ARBITRARY_OUTSIDE_DECIMAL = BigDecimal('0.123456789') + ARBITRARY_OUTSIDE_DATE = Date.jd(9999999) + ARBITRARY_OUTSIDE_DATETIME = DateTime.jd(9999999) + ARBITRARY_OUTSIDE_TIME = Time.at(9999999999) +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 dfe895e1a..a5efb15e5 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 +@@ -107,18 +107,18 @@ def validation_matcher_scenario_args + context 'against a decimal attribute' do + it_behaves_like 'it supports in_array', + possible_values: [1.0, 2.0, 3.0, 4.0, 5.0].map { |number| +- BigDecimal.new(number.to_s) ++ BigDecimal(number.to_s) + }, +- zero: BigDecimal.new('0.0'), ++ zero: BigDecimal('0.0'), + reserved_outside_value: described_class::ARBITRARY_OUTSIDE_DECIMAL + + it_behaves_like 'it supports in_range', +- possible_values: BigDecimal.new('1.0') .. BigDecimal.new('5.0'), +- zero: BigDecimal.new('0.0') ++ possible_values: BigDecimal('1.0') .. BigDecimal('5.0'), ++ zero: BigDecimal('0.0') + + def build_object(options = {}, &block) + build_object_with_generic_attribute( +- options.merge(column_type: :decimal, value: BigDecimal.new('1.0')), ++ options.merge(column_type: :decimal, value: BigDecimal('1.0')), + &block + ) + end +@@ -130,7 +130,7 @@ def add_outside_value_to(values) + def validation_matcher_scenario_args + super.deep_merge( + column_type: :decimal, +- default_value: BigDecimal.new('1.0') ++ default_value: BigDecimal('1.0') + ) + end + end + \ No newline at end of file diff --git a/fix-build-error.patch b/fix-build-error.patch new file mode 100644 index 0000000..ca4992d --- /dev/null +++ b/fix-build-error.patch @@ -0,0 +1,12 @@ +diff -Nur 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 +--- a/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb 2022-03-02 19:06:24.099019714 +0800 ++++ b/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb 2022-03-02 19:25:43.998524568 +0800 +@@ -79,7 +79,7 @@ + def with_index_on(column_name, index_options = {}) + create_table 'employees' do |table| + table.integer column_name +- end.add_index(:employees, column_name, index_options) ++ end.add_index(:employees, column_name, **index_options) + define_model_class('Employee').new + end + end diff --git a/fix-ruby-2.7-warning.patch b/fix-ruby-2.7-warning.patch new file mode 100644 index 0000000..2af30b0 --- /dev/null +++ b/fix-ruby-2.7-warning.patch @@ -0,0 +1,12 @@ +diff -Nur a/lib/shoulda/matchers/util/word_wrap.rb b/lib/shoulda/matchers/util/word_wrap.rb +--- a/lib/shoulda/matchers/util/word_wrap.rb 2022-03-02 17:01:03.260250272 +0800 ++++ b/lib/shoulda/matchers/util/word_wrap.rb 2022-03-02 17:00:26.059621102 +0800 +@@ -2,7 +2,7 @@ + module Matchers + # @private + def self.word_wrap(document, options = {}) +- Document.new(document, options).wrap ++ Document.new(document, **options).wrap + end + + # @private diff --git a/rubygem-shoulda-matchers.spec b/rubygem-shoulda-matchers.spec index 1f7632d..1b0f6f2 100644 --- a/rubygem-shoulda-matchers.spec +++ b/rubygem-shoulda-matchers.spec @@ -1,7 +1,7 @@ %global gem_name shoulda-matchers Name: rubygem-%{gem_name} Version: 3.1.2 -Release: 1 +Release: 2 Summary: Making tests easy on the fingers and eyes License: MIT URL: https://github.com/thoughtbot/shoulda-matchers @@ -21,6 +21,18 @@ Patch12: rubygem-shoulda-matchers-3.1.2-Fix-failing-association-matc Patch13: rubygem-shoulda-matchers-3.1.2-Fix-validate_inclusion_of-tests.patch Patch14: rubygem-shoulda-matchers-3.1.2-Use-correct-migration-class-in-acceptance-tests.patch Patch15: rubygem-shoulda-matchers-3.1.2-Define-respond_to_missing-on-ObjectDouble.patch +#https://github.com/thoughtbot/shoulda-matchers/commit/0c07bfb039b0fe9f9863e885ee3885e48f3b39d9 +Patch16: fix-bigdecimal-deprecated.patch +#https://github.com/thoughtbot/shoulda-matchers/pull/1427/commits/740930ee28dab97d14542d1ea7ad60e22b602ab3 +Patch17: Fix-warning-Using-the-last-argument-as-keyword-parameters-is-deprecated.patch +#https://github.com/thoughtbot/shoulda-matchers/pull/1406/commits/937256be204487727727cecc18519d85b91201d5 +Patch18: Handle-argument-delegation-for-ruby-3.patch +#https://github.com/thoughtbot/shoulda-matchers/pull/1406/commits/937256be204487727727cecc18519d85b91201d5 +Patch19: fix-ruby-2.7-warning.patch +#https://github.com/thoughtbot/shoulda-matchers/commit/ae9bf4a7355038e7e6ea13429abf815c6579f600 +Patch20: Add-minimal-support-For-rails-6.patch +#https://github.com/thoughtbot/shoulda-matchers/commit/d39685139f878ae7295320b4707a80f16a42d427 +Patch21: fix-build-error.patch BuildRequires: ruby(release) rubygems-devel ruby rubygem(activeresource) rubygem(bcrypt) BuildRequires: rubygem(jbuilder) rubygem(minitest-reporters) rubygem(rails) BuildRequires: rubygem(rails-controller-testing) rubygem(rspec) rubygem(rspec-rails) @@ -57,6 +69,12 @@ Documentation for %{name}. %patch14 -p1 %gemspec_add_file "spec/support/acceptance/helpers/rails_migration_helpers.rb" %patch15 -p1 +%patch16 -p1 +%patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 %build gem build ../%{gem_name}-%{version}.gemspec @@ -81,6 +99,8 @@ gem 'rspec-rails' gem 'sqlite3' gem 'spring' GF +mv spec/unit/shoulda/matchers/{active_record/association_matcher_spec.rb,active_model/helpers_spec.rb} ./ +mv spec/acceptance/{rails_integration_spec.rb,multiple_libraries_integration_spec.rb} ./ sed -i "/require 'pry/ s/^/#/" spec/spec_helper.rb sed -i "/current_bundle/ s/^/#/" spec/acceptance_spec_helper.rb sed -i "/assert_appraisal/ s/^/#/" spec/acceptance_spec_helper.rb @@ -128,5 +148,8 @@ popd %{gem_instdir}/zeus.json %changelog +* Thu Mar 3 2022 liyanan - 3.1.2-2 +- fix build error + * Mon Aug 10 2020 yanan li - 3.1.2-1 - Package init