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)