Skip to content

Commit

Permalink
Don't break when Pathname is passed to LoadedFeaturesIndex (#276)
Browse files Browse the repository at this point in the history
Don't break when Pathname is passed to LoadedFeaturesIndex
  • Loading branch information
burke committed Oct 18, 2019
2 parents 78be2f5 + 8d4b28a commit 9278a85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bootsnap/load_path_cache/loaded_features_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def register(short, long = nil)
#
# See <https://ruby-doc.org/core-2.6.4/Kernel.html#method-i-require>.
def extension_elidable?(f)
f.end_with?('.rb', '.so', '.o', '.dll', '.dylib')
f.to_s.end_with?('.rb', '.so', '.o', '.dll', '.dylib')
end

def strip_extension_if_elidable(f)
Expand Down
7 changes: 7 additions & 0 deletions test/load_path_cache/loaded_features_index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ def test_derives_initial_state_from_loaded_features
assert(index.key?('minitest/autorun.rb'))
refute(index.key?('minitest/autorun.so'))
end

def test_works_with_pathname
path = '/tmp/bundler.rb'
pathname = Pathname.new(path)
@index.register(pathname, path) { true }
assert(@index.key?(pathname))
end
end
end
end

0 comments on commit 9278a85

Please sign in to comment.