Permalink
Browse files

Add spec for File.basename and File.extname

Verifies the behavior when filenames have names with multibyte
characters.
  • Loading branch information...
dbussink committed Mar 25, 2013
1 parent 232a9c2 commit c2da2978dd8b6db1cbded907939f0cd9d6340881
Showing with 19 additions and 0 deletions.
  1. +10 −0 spec/ruby/core/file/basename_spec.rb
  2. +9 −0 spec/ruby/core/file/extname_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)
# TODO: Fix these
@@ -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
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)
describe "File.extname" do
@@ -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.