1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00

Update arity checks for Symbol#to_proc change

Ruby has [changed the arity of Symbol#to_proc from -1 to -2][ruby]. This commit
updates some arity checks we have in factory_bot to handle that case.
This should get the Ruby HEAD + Rails 6 tests passing on CI (the Ruby
head with other versions of Rails is still failing for various reasons).

[ruby]: 5b29ea0845
This commit is contained in:
Daniel Colson 2020-07-16 12:25:57 -04:00
parent 793a651aa3
commit 37bc11d720
2 changed files with 2 additions and 2 deletions

View file

@ -12,7 +12,7 @@ module FactoryBot
-> { -> {
value = case block.arity value = case block.arity
when 1, -1 then instance_exec(self, &block) when 1, -1, -2 then instance_exec(self, &block)
else instance_exec(&block) else instance_exec(&block)
end end
raise SequenceAbuseError if FactoryBot::Sequence === value raise SequenceAbuseError if FactoryBot::Sequence === value

View file

@ -9,7 +9,7 @@ module FactoryBot
def run(instance, evaluator) def run(instance, evaluator)
case block.arity case block.arity
when 1, -1 then syntax_runner.instance_exec(instance, &block) when 1, -1, -2 then syntax_runner.instance_exec(instance, &block)
when 2 then syntax_runner.instance_exec(instance, evaluator, &block) when 2 then syntax_runner.instance_exec(instance, evaluator, &block)
else syntax_runner.instance_exec(&block) else syntax_runner.instance_exec(&block)
end end