From c3c8171840bd71557450761bb1842f3a485aa6ca Mon Sep 17 00:00:00 2001 From: Kjetil Torgrim Homme Date: Sun, 10 Dec 2023 22:13:47 +0100 Subject: [PATCH] Skip non-existing paths in $MODULEPATH silently In `map`, a `next` will leave a `nil` value in the array. This is a problem since `FileTest.directory? nil` raises "TypeError: no implicit conversion of nil into String" Bug was introduced in v4.0.1, in commit b6bfd6f6853dfbfafd2841e4580f79e312b7cc4a --- lib/puppetlabs_spec_helper/module_spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppetlabs_spec_helper/module_spec_helper.rb b/lib/puppetlabs_spec_helper/module_spec_helper.rb index e691d50f..412c0a9e 100644 --- a/lib/puppetlabs_spec_helper/module_spec_helper.rb +++ b/lib/puppetlabs_spec_helper/module_spec_helper.rb @@ -58,7 +58,7 @@ def verify_contents(subject, title, expected_lines) Dir.entries(dir).grep_v(/^\./).map { |f| File.join(dir, f, 'spec', 'lib') } end -components.flatten.each do |d| +components.compact.flatten.each do |d| $LOAD_PATH << d if FileTest.directory?(d) && !$LOAD_PATH.include?(d) end