mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
5c071d42fd
Ruby 2.7 deprecated passing kwargs when the method expects a hash or passing a hash when the method expects kwargs. In factory_bot, this creates the warning: ``` /Users/hparker/code/factory_bot/lib/factory_bot/decorator/new_constructor.rb:9: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /Users/hparker/code/factory_bot/spec/acceptance/initialize_with_spec.rb:220: warning: The called method `initialize' is defined here ``` We can fix this warning by updating the syntax. We need to include `**kwargs` in the `method_missing` calls when we are on ruby 2.7 or later. In decorator.rb, adding `**kwargs` alone doesn't work since adding `**kwargs` can change what arguments remain in the `args`. In this case we have to class eval the method if we are running ruby 2.7. This way the syntax is valid in previous versions and we can use the `...` operator which allows us to avoid changing the arguments passed on in method missing. Co-authored-by: Lee Quarella <leequarella@gmail.com> |
||
---|---|---|
.. | ||
attribute | ||
declaration | ||
decorator | ||
strategy | ||
syntax | ||
aliases.rb | ||
attribute.rb | ||
attribute_assigner.rb | ||
attribute_list.rb | ||
callback.rb | ||
callbacks_observer.rb | ||
configuration.rb | ||
declaration.rb | ||
declaration_list.rb | ||
decorator.rb | ||
definition.rb | ||
definition_hierarchy.rb | ||
definition_proxy.rb | ||
enum.rb | ||
errors.rb | ||
evaluation.rb | ||
evaluator.rb | ||
evaluator_class_definer.rb | ||
factory.rb | ||
factory_runner.rb | ||
find_definitions.rb | ||
internal.rb | ||
linter.rb | ||
null_factory.rb | ||
null_object.rb | ||
registry.rb | ||
reload.rb | ||
sequence.rb | ||
strategy_calculator.rb | ||
strategy_syntax_method_registrar.rb | ||
syntax.rb | ||
syntax_runner.rb | ||
trait.rb | ||
version.rb |