1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_bot
Adam Hess 5c071d42fd Fix ruby 2.7 kwargs warning
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>
2020-06-24 18:27:38 -04:00
..
attribute Run standardrb 2020-06-10 17:11:39 -04:00
declaration Raise more helpful error for invalid attribute 2020-06-22 20:01:32 -04:00
decorator Fix ruby 2.7 kwargs warning 2020-06-24 18:27:38 -04:00
strategy Run standardrb 2020-06-10 17:11:39 -04:00
syntax Run standardrb 2020-06-10 17:11:39 -04:00
aliases.rb Run standardrb 2020-06-10 17:11:39 -04:00
attribute.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
attribute_assigner.rb Run standardrb 2020-06-10 17:11:39 -04:00
attribute_list.rb Run standardrb 2020-06-10 17:11:39 -04:00
callback.rb Run standardrb 2020-06-10 17:11:39 -04:00
callbacks_observer.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
configuration.rb Run standardrb 2020-06-10 17:11:39 -04:00
declaration.rb Run standardrb 2020-06-10 17:11:39 -04:00
declaration_list.rb Run standardrb 2020-06-10 17:11:39 -04:00
decorator.rb Fix ruby 2.7 kwargs warning 2020-06-24 18:27:38 -04:00
definition.rb Ensure enum traits only get expanded once 2020-06-19 23:44:32 -04:00
definition_hierarchy.rb Deprecate remaining undocumented internal methods 2020-04-23 19:35:39 -04:00
definition_proxy.rb Run standardrb 2020-06-10 17:11:39 -04:00
enum.rb Add functionality for enum traits (#1380) 2020-05-01 17:50:51 -04:00
errors.rb Fix self referencing trait error (#1294) 2019-09-10 16:24:20 -07:00
evaluation.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
evaluator.rb Fix ruby 2.7 kwargs warning 2020-06-24 18:27:38 -04:00
evaluator_class_definer.rb Run standardrb 2020-06-10 17:11:39 -04:00
factory.rb Run standardrb 2020-06-10 17:11:39 -04:00
factory_runner.rb Run standardrb 2020-06-10 17:11:39 -04:00
find_definitions.rb Run standardrb 2020-06-10 17:11:39 -04:00
internal.rb Run standardrb 2020-06-10 17:11:39 -04:00
linter.rb Run standardrb 2020-06-10 17:11:39 -04:00
null_factory.rb Run standardrb 2020-06-10 17:11:39 -04:00
null_object.rb Remove unused _include_private argument 2020-06-02 12:18:04 -04:00
registry.rb Run standardrb 2020-06-10 17:11:39 -04:00
reload.rb Remove code for registering callbacks 2020-05-29 14:52:23 -04:00
sequence.rb Run standardrb 2020-06-10 17:11:39 -04:00
strategy_calculator.rb Deprecate/Move strategies and callback methods 2019-06-04 20:09:14 -04:00
strategy_syntax_method_registrar.rb Pass index to block for *_list methods 2020-04-24 11:36:17 -04:00
syntax.rb Rubocop: Fix Style/StringLiterals Offenses (#1216) 2018-10-07 21:45:51 -04:00
syntax_runner.rb Replace 'girl' with 'bot' everywhere (#1051) 2017-10-20 15:20:28 -04:00
trait.rb Run standardrb 2020-06-10 17:11:39 -04:00
version.rb Bump version to v6.0.2 [ci skip] 2020-06-19 23:50:07 -04:00