Skip to content

Commit

Permalink
Add spec for File.basename and File.extname
Browse files Browse the repository at this point in the history
Verifies the behavior when filenames have names with multibyte
characters.
  • Loading branch information
dbussink committed Mar 25, 2013
1 parent 232a9c2 commit c2da297
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/ruby/core/file/basename_spec.rb
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)

# TODO: Fix these
Expand Down Expand Up @@ -140,4 +141,13 @@
File.basename("c:\\bar.txt.exe", ".*").should == "bar.txt"
end
end

with_feature :encoding do

it "returns the extension for a multibyte filename" do
File.basename('/path/Офис.m4a').should == "Офис.m4a"
end

end

end
9 changes: 9 additions & 0 deletions spec/ruby/core/file/extname_spec.rb
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)

describe "File.extname" do
Expand Down Expand Up @@ -44,4 +45,12 @@
lambda { File.extname }.should raise_error(ArgumentError)
lambda { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError)
end

with_feature :encoding do

it "returns the extension for a multibyte filename" do
File.extname('Имя.m4a').should == ".m4a"
end

end
end

0 comments on commit c2da297

Please sign in to comment.