diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-28 15:15:48 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-28 15:15:48 +0000 |
commit | 8c5b60eb22d6d661e87992a65d54e3a5bc0aeed4 (patch) | |
tree | 7905b284cb5b3d62c17ad8a939e339621a498a2c /spec/ruby/core/file | |
parent | 6530b14cee76e2512424d225e64d3c61dd1f6511 (diff) | |
download | ruby-8c5b60eb22d6d661e87992a65d54e3a5bc0aeed4.tar.gz |
Update to ruby/spec@a6b8805
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r-- | spec/ruby/core/file/empty_spec.rb | 15 | ||||
-rw-r--r-- | spec/ruby/core/file/readlink_spec.rb | 23 | ||||
-rw-r--r-- | spec/ruby/core/file/shared/fnmatch.rb | 10 |
3 files changed, 41 insertions, 7 deletions
diff --git a/spec/ruby/core/file/empty_spec.rb b/spec/ruby/core/file/empty_spec.rb new file mode 100644 index 0000000000..766aa95e46 --- /dev/null +++ b/spec/ruby/core/file/empty_spec.rb @@ -0,0 +1,15 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../../../shared/file/zero', __FILE__) + +describe "File.empty?" do + ruby_version_is "2.4" do + it_behaves_like :file_zero, :empty?, File + it_behaves_like :file_zero_missing, :empty?, File + + platform_is :solaris do + it "returns false for /dev/null" do + File.empty?('/dev/null').should == true + end + end + end +end diff --git a/spec/ruby/core/file/readlink_spec.rb b/spec/ruby/core/file/readlink_spec.rb index 6db2c09780..b529cd1355 100644 --- a/spec/ruby/core/file/readlink_spec.rb +++ b/spec/ruby/core/file/readlink_spec.rb @@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__) describe "File.readlink" do # symlink/readlink are not supported on Windows platform_is_not :windows do - describe "File.readlink with absolute paths" do + describe "with absolute paths" do before :each do @file = tmp('file_readlink.txt') @link = tmp('file_readlink.lnk') @@ -35,7 +35,26 @@ describe "File.readlink" do end end - describe "File.readlink when changing the working directory" do + describe "with paths containing unicode characters" do + before :each do + @file = tmp('tàrget.txt') + @link = tmp('lïnk.lnk') + File.symlink(@file, @link) + end + + after :each do + rm_r @file, @link + end + + it "returns the name of the file referenced by the given link" do + touch @file + result = File.readlink(@link) + result.encoding.should equal Encoding.find('filesystem') + result.should == @file.dup.force_encoding(Encoding.find('filesystem')) + end + end + + describe "when changing the working directory" do before :each do @cwd = Dir.pwd @tmpdir = tmp("/readlink") diff --git a/spec/ruby/core/file/shared/fnmatch.rb b/spec/ruby/core/file/shared/fnmatch.rb index 80e37b3fff..9b423ae47e 100644 --- a/spec/ruby/core/file/shared/fnmatch.rb +++ b/spec/ruby/core/file/shared/fnmatch.rb @@ -75,11 +75,11 @@ describe :file_fnmatch, shared: true do File.send(@method, 'c*t', 'c/a/b/t').should == true end - it "matches ranges of characters using bracket expresions (e.g. [a-z])" do + it "matches ranges of characters using bracket expression (e.g. [a-z])" do File.send(@method, 'ca[a-z]', 'cat').should == true end - it "matches ranges of characters using bracket expresions, taking case into account" do + it "matches ranges of characters using bracket expression, taking case into account" do File.send(@method, '[a-z]', 'D').should == false File.send(@method, '[^a-z]', 'D').should == true File.send(@method, '[A-Z]', 'd').should == false @@ -92,7 +92,7 @@ describe :file_fnmatch, shared: true do File.send(@method, '/ca[s][s-t]/rul[a-b]/[z]he/[x-Z]orld', '/cats/rule/the/World').should == false end - it "matches ranges of characters using exclusive bracket expresions (e.g. [^t] or [!t])" do + it "matches ranges of characters using exclusive bracket expression (e.g. [^t] or [!t])" do File.send(@method, 'ca[^t]', 'cat').should == false File.send(@method, 'ca[!t]', 'cat').should == false end @@ -106,13 +106,13 @@ describe :file_fnmatch, shared: true do end platform_is_not :windows do - it "doesn't match case sensitive characters on platfroms with case sensitive paths, when flags include FNM_SYSCASE" do + it "doesn't match case sensitive characters on platforms with case sensitive paths, when flags include FNM_SYSCASE" do File.send(@method, 'cat', 'CAT', File::FNM_SYSCASE).should == false end end platform_is :windows do - it "matches case sensitive characters on platfroms with case insensitive paths, when flags include FNM_SYSCASE" do + it "matches case sensitive characters on platforms with case insensitive paths, when flags include FNM_SYSCASE" do File.send(@method, 'cat', 'CAT', File::FNM_SYSCASE).should == true end end |