From e41c6262111aa118b82a8a07390000b4a6e4793b Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Fri, 6 Dec 2024 16:28:51 -0800 Subject: [PATCH] guard against nil key and @referenced if `key` and `@referenced` are both nil, we will try to access @referenced.last and explode like this: ``` oaken-0.7.0/lib/generators/oaken/convert/fixtures_generator.rb:54:in `recursive_convert': undefined method `last' for nil (NoMethodError) @referenced.last == :plural ? "[#{input}]" : input ``` this patch resolved the issue and allowed me to run the generator successfully. --- lib/generators/oaken/convert/fixtures_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/oaken/convert/fixtures_generator.rb b/lib/generators/oaken/convert/fixtures_generator.rb index c763062..8b2ad3c 100644 --- a/lib/generators/oaken/convert/fixtures_generator.rb +++ b/lib/generators/oaken/convert/fixtures_generator.rb @@ -50,7 +50,7 @@ def recursive_convert(input, key: nil) when Array then input.map { recursive_convert _1 }.join(", ") when Integer then input else - if key == @referenced&.first + if key && key == @referenced&.first @referenced.last == :plural ? "[#{input}]" : input else "\"#{input}\""