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/spec
Daniel Colson 793a651aa3 Address Ruby 2.7 kwargs edge case
Closes #1423

5c071d42 fixed most kwarg deprecation warnings coming from within
factory_bot, but using the Ruby 3-style argument forwarding does not
handle every case.

To handle the case of `initialize_with` being used with a method that
takes a final hash argument, this commit adds an additional branch to
this code to use `ruby2_keywords` for Ruby >= 2.7 and < 3.0. On 3.0 we
use the 3.0-style forwarding.

I added a tests that was outputting a deprecation warning on Ruby 2.7
before this change, but that no longer outputs the warning after this
change.

Yes, this is a bit of a mess, but I don't see a better way. I got
inspiration here from this [fantastic blog post on argument delegating
with Ruby 2.7 and 3][delegating].

[delegating]: https://eregon.me/blog/2019/11/10/the-delegation-challenge-of-ruby27.html#the-delegation-challenge.
2020-07-16 09:10:06 -04:00
..
acceptance Address Ruby 2.7 kwargs edge case 2020-07-16 09:10:06 -04:00
factory_bot Add back did_you_mean spec 2020-07-10 12:14:40 -04:00
support Run standardrb 2020-06-10 17:11:39 -04:00
factory_bot_spec.rb Run standardrb 2020-06-10 17:11:39 -04:00
spec_helper.rb Adjust use_parent_strategy safely in specs 2019-08-12 18:54:53 +01:00