Skip to content

Commit

Permalink
Dealing with trailing slashes in looked-up paths (fixes #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonc committed Jan 1, 2017
1 parent e052f0a commit da103bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/memfs/fake/directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def entry_names
end

def find(path)
path = path.sub(%r{\A/+}, '')
path = path.sub(%r{\A/+}, '').sub(%r{/+\z}, '')
parts = path.split('/', 2)

if entry_names.include?(path)
Expand Down
4 changes: 4 additions & 0 deletions spec/memfs/fake/directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ module Fake
it 'should remove any leading / in the path' do
expect(directory.find('/sub_dir/file')).to be(file)
end

it 'should remove any trailing / in the path' do
expect(directory.find('sub_dir/file/')).to be(file)
end
end

describe '#parent=' do
Expand Down

0 comments on commit da103bb

Please sign in to comment.