diff --git a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb index 34d5e5c80..a3377fbf8 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb @@ -56,6 +56,7 @@ def indexables load_path_entry = T.let(nil, T.nilable(String)) Dir.glob(pattern, File::FNM_PATHNAME | File::FNM_EXTGLOB).map! do |path| + path = File.expand_path(path) # All entries for the same pattern match the same $LOAD_PATH entry. Since searching the $LOAD_PATH for every # entry is expensive, we memoize it until we find a path that doesn't belong to that $LOAD_PATH. This happens # on repositories that define multiple gems, like Rails. All frameworks are defined inside the Dir.pwd, but diff --git a/lib/ruby_indexer/test/configuration_test.rb b/lib/ruby_indexer/test/configuration_test.rb index 09a342815..e7e774e6e 100644 --- a/lib/ruby_indexer/test/configuration_test.rb +++ b/lib/ruby_indexer/test/configuration_test.rb @@ -20,6 +20,14 @@ def test_load_configuration_executes_configure_block assert(indexables.none? { |indexable| indexable.full_path == __FILE__ }) end + def test_indexables_have_expanded_full_paths + @config.apply_config({ "included_patterns" => ["**/*.rb"] }) + indexables = @config.indexables + + # All paths should be expanded + assert(indexables.none? { |indexable| indexable.full_path.start_with?("lib/") }) + end + def test_indexables_only_includes_gem_require_paths indexables = @config.indexables