From 76e72a62989970a9ccb60c4c292a9ff936413442 Mon Sep 17 00:00:00 2001 From: Guilherme Silva Date: Mon, 11 Nov 2024 13:22:47 -0300 Subject: [PATCH] fix to used ruby 2.7 --- lib/factory_bot/definition_proxy.rb | 6 ++++-- lib/factory_bot/evaluator.rb | 8 ++++---- lib/factory_bot/syntax/default.rb | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/factory_bot/definition_proxy.rb b/lib/factory_bot/definition_proxy.rb index a27c33f2..7ba8cab4 100644 --- a/lib/factory_bot/definition_proxy.rb +++ b/lib/factory_bot/definition_proxy.rb @@ -88,6 +88,8 @@ def transient(&block) # end # # are equivalent. + + def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing association_options = args.first @@ -119,8 +121,8 @@ def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondTo # end # # Except that no globally available sequence will be defined. - def sequence(name, ...) - sequence = Sequence.new(name, ...) + def sequence(name, *args, &block) + sequence = Sequence.new(name, *args, &block) FactoryBot::Internal.register_inline_sequence(sequence) add_attribute(name) { increment_sequence(sequence) } end diff --git a/lib/factory_bot/evaluator.rb b/lib/factory_bot/evaluator.rb index 7a4b82e7..55d5cb85 100644 --- a/lib/factory_bot/evaluator.rb +++ b/lib/factory_bot/evaluator.rb @@ -35,11 +35,11 @@ def association(factory_name, *traits_and_overrides) attr_accessor :instance - def method_missing(method_name, ...) + def method_missing(method_name, *args, &block) # Correção: adicionados *args e &block if @instance.respond_to?(method_name) - @instance.send(method_name, ...) + @instance.send(method_name, *args, &block) # Correção: adicionados *args e &block else - SyntaxRunner.new.send(method_name, ...) + SyntaxRunner.new.send(method_name, *args, &block) # Correção: adicionados *args e &block end end @@ -77,4 +77,4 @@ def self.define_attribute(name, &block) end end end -end +end \ No newline at end of file diff --git a/lib/factory_bot/syntax/default.rb b/lib/factory_bot/syntax/default.rb index 66f4d2c7..54c9efc9 100644 --- a/lib/factory_bot/syntax/default.rb +++ b/lib/factory_bot/syntax/default.rb @@ -25,8 +25,8 @@ def factory(name, options = {}, &block) end end - def sequence(name, ...) - Internal.register_sequence(Sequence.new(name, ...)) + def sequence(name, *args, &block) + register_sequence(Sequence.new(name, *args, &block)) end def trait(name, &block)