diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-04-28 23:20:11 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-04-28 23:20:11 +0200 |
commit | 79671ec57e59091260a0bc3d40a31d31d9c72a94 (patch) | |
tree | 2f59a8727b8f63f9e79d50352fa4f78a7cc00234 /spec/ruby/core/file | |
parent | 994833085ae06afbe94d30ab183d80e0234fbe14 (diff) | |
download | ruby-79671ec57e59091260a0bc3d40a31d31d9c72a94.tar.gz |
Update to ruby/spec@7de852d
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r-- | spec/ruby/core/file/basename_spec.rb | 18 | ||||
-rw-r--r-- | spec/ruby/core/file/expand_path_spec.rb | 54 | ||||
-rw-r--r-- | spec/ruby/core/file/extname_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/file/open_spec.rb | 19 | ||||
-rw-r--r-- | spec/ruby/core/file/shared/path.rb | 10 |
5 files changed, 41 insertions, 68 deletions
diff --git a/spec/ruby/core/file/basename_spec.rb b/spec/ruby/core/file/basename_spec.rb index 671955302a..50365b1125 100644 --- a/spec/ruby/core/file/basename_spec.rb +++ b/spec/ruby/core/file/basename_spec.rb @@ -153,18 +153,16 @@ describe "File.basename" do end end - with_feature :encoding do - it "returns the extension for a multibyte filename" do - File.basename('/path/Офис.m4a').should == "Офис.m4a" - end - - it "returns the basename with the same encoding as the original" do - basename = File.basename('C:/Users/Scuby Pagrubý'.encode(Encoding::Windows_1250)) - basename.should == 'Scuby Pagrubý'.encode(Encoding::Windows_1250) - basename.encoding.should == Encoding::Windows_1250 - end + it "returns the extension for a multibyte filename" do + File.basename('/path/Офис.m4a').should == "Офис.m4a" + end + it "returns the basename with the same encoding as the original" do + basename = File.basename('C:/Users/Scuby Pagrubý'.encode(Encoding::Windows_1250)) + basename.should == 'Scuby Pagrubý'.encode(Encoding::Windows_1250) + basename.encoding.should == Encoding::Windows_1250 end + end diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index 5bb60d2c23..90aa44e2c4 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -19,14 +19,12 @@ describe "File.expand_path" do end end - with_feature :encoding do - before :each do - @external = Encoding.default_external - end + before :each do + @external = Encoding.default_external + end - after :each do - Encoding.default_external = @external - end + after :each do + Encoding.default_external = @external end it "converts a pathname to an absolute pathname" do @@ -136,34 +134,32 @@ describe "File.expand_path" do end end - with_feature :encoding do - it "returns a String in the same encoding as the argument" do - Encoding.default_external = Encoding::SHIFT_JIS + it "returns a String in the same encoding as the argument" do + Encoding.default_external = Encoding::SHIFT_JIS - path = "./a".force_encoding Encoding::CP1251 - File.expand_path(path).encoding.should equal(Encoding::CP1251) + path = "./a".force_encoding Encoding::CP1251 + File.expand_path(path).encoding.should equal(Encoding::CP1251) - weird_path = [222, 173, 190, 175].pack('C*') - File.expand_path(weird_path).encoding.should equal(Encoding::ASCII_8BIT) - end + weird_path = [222, 173, 190, 175].pack('C*') + File.expand_path(weird_path).encoding.should equal(Encoding::ASCII_8BIT) + end - platform_is_not :windows do - it "expands a path when the default external encoding is ASCII-8BIT" do - Encoding.default_external = Encoding::ASCII_8BIT - path_8bit = [222, 173, 190, 175].pack('C*') - File.expand_path( path_8bit, @rootdir).should == "#{@rootdir}" + path_8bit - end + platform_is_not :windows do + it "expands a path when the default external encoding is ASCII-8BIT" do + Encoding.default_external = Encoding::ASCII_8BIT + path_8bit = [222, 173, 190, 175].pack('C*') + File.expand_path( path_8bit, @rootdir).should == "#{@rootdir}" + path_8bit end + end - it "expands a path with multi-byte characters" do - File.expand_path("Ångström").should == "#{@base}/Ångström" - end + it "expands a path with multi-byte characters" do + File.expand_path("Ångström").should == "#{@base}/Ångström" + end - platform_is_not :windows do - it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do - Encoding.default_external = Encoding::UTF_16BE - lambda { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError) - end + platform_is_not :windows do + it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do + Encoding.default_external = Encoding::UTF_16BE + lambda { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError) end end diff --git a/spec/ruby/core/file/extname_spec.rb b/spec/ruby/core/file/extname_spec.rb index 1513b30e90..7632b6adc0 100644 --- a/spec/ruby/core/file/extname_spec.rb +++ b/spec/ruby/core/file/extname_spec.rb @@ -44,11 +44,9 @@ describe "File.extname" do 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 + it "returns the extension for a multibyte filename" do + File.extname('Имя.m4a').should == ".m4a" end + end diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index 9e98d3d88a..14be5aa32a 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -165,23 +165,6 @@ describe "File.open" do File.exist?(@file).should == true end - without_feature :mjit do # [ruby-core:90895] MJIT worker may leave fd open in a forked child. TODO: consider acquiring GVL from MJIT worker. - it "opens a file with a file descriptor d and a block" do - @fh = File.open(@file) - @fh.should be_kind_of(File) - - lambda { - File.open(@fh.fileno) do |fh| - @fd = fh.fileno - @fh.close - end - }.should raise_error(Errno::EBADF) - lambda { File.open(@fd) }.should raise_error(Errno::EBADF) - - File.exist?(@file).should == true - end - end - it "opens a file that no exists when use File::WRONLY mode" do lambda { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT) end @@ -673,7 +656,7 @@ describe "File.open when passed a file descriptor" do before do @content = "File#open when passed a file descriptor" @name = tmp("file_open_with_fd.txt") - @fd = new_fd @name, fmode("w:utf-8") + @fd = new_fd @name, "w:utf-8" @file = nil end diff --git a/spec/ruby/core/file/shared/path.rb b/spec/ruby/core/file/shared/path.rb index 503e485f1e..9df3416c89 100644 --- a/spec/ruby/core/file/shared/path.rb +++ b/spec/ruby/core/file/shared/path.rb @@ -44,12 +44,10 @@ describe :file_path, shared: true do end end - with_feature :encoding do - it "preserves the encoding of the path" do - path = @path.force_encoding("euc-jp") - @file = File.new path - @file.send(@method).encoding.should == Encoding.find("euc-jp") - end + it "preserves the encoding of the path" do + path = @path.force_encoding("euc-jp") + @file = File.new path + @file.send(@method).encoding.should == Encoding.find("euc-jp") end ruby_version_is "2.5" do |