Skip to content

Commit

Permalink
File::extname Ruby 2.7 behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
aried3r committed Jan 7, 2020
1 parent 9d97e17 commit 621b81b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/memfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def self.ruby_version_gte?(version) # :nodoc:
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(version)
end

def self.windows?
/mswin|bccwin|mingw/ =~ RUBY_PLATFORM
end

require 'memfs/file_system'
require 'memfs/dir'
require 'memfs/file'
Expand Down
13 changes: 10 additions & 3 deletions spec/memfs/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,16 @@ module MemFs
end

context 'when the period is the last character in path' do
it 'returns an empty string' do
extname = described_class.extname('test-subject.')
expect(extname).to eq ''
if MemFs.ruby_version_gte?('2.7') && !MemFs.windows?
it 'returns a period' do
extname = described_class.extname('test-subject.')
expect(extname).to eq '.'
end
else
it 'returns an empty string' do
extname = described_class.extname('test-subject.')
expect(extname).to eq ''
end
end
end
end
Expand Down

0 comments on commit 621b81b

Please sign in to comment.