aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/file
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-09-29 19:13:37 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-09-29 19:13:37 +0200
commit070cbe22b70ec2bec36c7cfc84b726510afa306f (patch)
tree56cee87834c85bd9f358ebee51bab4893fb9952f /spec/ruby/core/file
parentd51b4e34fbdbe1a845aa2251b1fa3304de809b32 (diff)
downloadruby-070cbe22b70ec2bec36c7cfc84b726510afa306f.tar.gz
Update to ruby/spec@34e6246
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r--spec/ruby/core/file/link_spec.rb2
-rw-r--r--spec/ruby/core/file/new_spec.rb26
-rw-r--r--spec/ruby/core/file/open_spec.rb42
-rw-r--r--spec/ruby/core/file/rename_spec.rb8
-rw-r--r--spec/ruby/core/file/shared/path.rb3
-rw-r--r--spec/ruby/core/file/shared/unlink.rb10
-rw-r--r--spec/ruby/core/file/world_readable_spec.rb2
-rw-r--r--spec/ruby/core/file/world_writable_spec.rb2
8 files changed, 47 insertions, 48 deletions
diff --git a/spec/ruby/core/file/link_spec.rb b/spec/ruby/core/file/link_spec.rb
index 11d4c8d25b..cc63c76aa3 100644
--- a/spec/ruby/core/file/link_spec.rb
+++ b/spec/ruby/core/file/link_spec.rb
@@ -16,7 +16,7 @@ describe "File.link" do
platform_is_not :windows do
it "link a file with another" do
File.link(@file, @link).should == 0
- File.exist?(@link).should == true
+ File.should.exist?(@link)
File.identical?(@file, @link).should == true
end
diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb
index e99f6ba72b..004f78503a 100644
--- a/spec/ruby/core/file/new_spec.rb
+++ b/spec/ruby/core/file/new_spec.rb
@@ -17,13 +17,13 @@ describe "File.new" do
it "returns a new File with mode string" do
@fh = File.new(@file, 'w')
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "returns a new File with mode num" do
@fh = File.new(@file, @flags)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "returns a new File with modus num and permissions" do
@@ -34,7 +34,7 @@ describe "File.new" do
platform_is_not :windows do
File.stat(@file).mode.to_s(8).should == "100744"
end
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do
@@ -48,7 +48,7 @@ describe "File.new" do
ensure
f.close
end
- File.exist?(@file).should == true
+ File.should.exist?(@file)
File.read(@file).should == "test\n"
end
@@ -75,13 +75,13 @@ describe "File.new" do
fh_copy = File.new(@fh.fileno)
fh_copy.autoclose = false
fh_copy.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "creates a new file when use File::EXCL mode" do
@fh = File.new(@file, File::EXCL)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "raises an Errorno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do
@@ -91,46 +91,46 @@ describe "File.new" do
it "creates a new file when use File::WRONLY|File::APPEND mode" do
@fh = File.new(@file, File::WRONLY|File::APPEND)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "returns a new File when use File::APPEND mode" do
@fh = File.new(@file, File::APPEND)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "returns a new File when use File::RDONLY|File::APPEND mode" do
@fh = File.new(@file, File::RDONLY|File::APPEND)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "returns a new File when use File::RDONLY|File::WRONLY mode" do
@fh = File.new(@file, File::RDONLY|File::WRONLY)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "creates a new file when use File::WRONLY|File::TRUNC mode" do
@fh = File.new(@file, File::WRONLY|File::TRUNC)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "coerces filename using to_str" do
name = mock("file")
name.should_receive(:to_str).and_return(@file)
@fh = File.new(name, "w")
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "coerces filename using #to_path" do
name = mock("file")
name.should_receive(:to_path).and_return(@file)
@fh = File.new(name, "w")
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "raises a TypeError if the first parameter can't be coerced to a string" do
diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb
index b6af2686e4..93f1972ac6 100644
--- a/spec/ruby/core/file/open_spec.rb
+++ b/spec/ruby/core/file/open_spec.rb
@@ -63,40 +63,40 @@ describe "File.open" do
it "opens the file (basic case)" do
@fh = File.open(@file)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens the file with unicode characters" do
@fh = File.open(@unicode_path, "w")
@fh.should be_kind_of(File)
- File.exist?(@unicode_path).should == true
+ File.should.exist?(@unicode_path)
end
it "opens a file when called with a block" do
File.open(@file) { |fh| }
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens with mode string" do
@fh = File.open(@file, 'w')
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file with mode string and block" do
File.open(@file, 'w') { |fh| }
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file with mode num" do
@fh = File.open(@file, @flags)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file with mode num and block" do
File.open(@file, 'w') { |fh| }
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file with mode and permission as nil" do
@@ -113,7 +113,7 @@ describe "File.open" do
platform_is_not :windows do
@fh.lstat.mode.to_s(8).should == "100744"
end
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
# For this test we delete the file first to reset the perms
@@ -124,7 +124,7 @@ describe "File.open" do
platform_is_not :windows do
File.stat(@file).mode.to_s(8).should == "100755"
end
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do
@@ -162,7 +162,7 @@ describe "File.open" do
fh_copy = File.open(@fh.fileno)
fh_copy.autoclose = false
fh_copy.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file that no exists when use File::WRONLY mode" do
@@ -206,19 +206,19 @@ describe "File.open" do
it "opens a file that no exists when use File::CREAT mode" do
@fh = File.open(@nonexistent, File::CREAT) { |f| f }
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file that no exists when use 'a' mode" do
@fh = File.open(@nonexistent, 'a') { |f| f }
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file that no exists when use 'w' mode" do
@fh = File.open(@nonexistent, 'w') { |f| f }
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
# Check the grants associated to the different open modes combinations.
@@ -365,7 +365,7 @@ describe "File.open" do
it "creates a new file when use File::WRONLY|File::APPEND mode" do
@fh = File.open(@file, File::WRONLY|File::APPEND)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file when use File::WRONLY|File::APPEND mode" do
@@ -408,7 +408,7 @@ describe "File.open" do
begin
@fh = File.open(@file, File::WRONLY|File::TRUNC)
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
ensure
fh1.close
end
@@ -471,13 +471,13 @@ describe "File.open" do
it "opens a file for binary read" do
@fh = File.open(@file, "rb")
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file for binary write" do
@fh = File.open(@file, "wb")
@fh.should be_kind_of(File)
- File.exist?(@file).should == true
+ File.should.exist?(@file)
end
it "opens a file for read-write and truncate the file" do
@@ -523,10 +523,10 @@ describe "File.open" do
io.read.should == "ruby"
Dir["#{dir}/*"].should == []
end
- rescue Errno::EOPNOTSUPP, Errno::EINVAL, Errno::EISDIR
- # EOPNOTSUPP: no support from the filesystem
- # EINVAL: presumably bug in glibc
- 1.should == 1
+ rescue Errno::EOPNOTSUPP
+ skip "no support from the filesystem"
+ rescue Errno::EINVAL, Errno::EISDIR
+ skip "presumably bug in glibc"
ensure
rm_r dir
end
diff --git a/spec/ruby/core/file/rename_spec.rb b/spec/ruby/core/file/rename_spec.rb
index d903e7a0d5..f2c18d4905 100644
--- a/spec/ruby/core/file/rename_spec.rb
+++ b/spec/ruby/core/file/rename_spec.rb
@@ -14,11 +14,11 @@ describe "File.rename" do
end
it "renames a file" do
- File.exist?(@old).should == true
- File.exist?(@new).should == false
+ File.should.exist?(@old)
+ File.should_not.exist?(@new)
File.rename(@old, @new)
- File.exist?(@old).should == false
- File.exist?(@new).should == true
+ File.should_not.exist?(@old)
+ File.should.exist?(@new)
end
it "raises an Errno::ENOENT if the source does not exist" do
diff --git a/spec/ruby/core/file/shared/path.rb b/spec/ruby/core/file/shared/path.rb
index 9df3416c89..cfd119f799 100644
--- a/spec/ruby/core/file/shared/path.rb
+++ b/spec/ruby/core/file/shared/path.rb
@@ -68,8 +68,7 @@ describe :file_path, shared: true do
-> { f.send(@method) }.should raise_error(IOError)
end
rescue Errno::EOPNOTSUPP, Errno::EINVAL, Errno::EISDIR
- # EOPNOTSUPP: no support from the filesystem
- 1.should == 1
+ skip "no support from the filesystem"
end
end
end
diff --git a/spec/ruby/core/file/shared/unlink.rb b/spec/ruby/core/file/shared/unlink.rb
index d72ab4701f..e339e93271 100644
--- a/spec/ruby/core/file/shared/unlink.rb
+++ b/spec/ruby/core/file/shared/unlink.rb
@@ -21,13 +21,13 @@ describe :file_unlink, shared: true do
it "deletes a single file" do
File.send(@method, @file1).should == 1
- File.exist?(@file1).should == false
+ File.should_not.exist?(@file1)
end
it "deletes multiple files" do
File.send(@method, @file1, @file2).should == 2
- File.exist?(@file1).should == false
- File.exist?(@file2).should == false
+ File.should_not.exist?(@file1)
+ File.should_not.exist?(@file2)
end
it "raises a TypeError if not passed a String type" do
@@ -52,10 +52,10 @@ describe :file_unlink, shared: true do
it "allows deleting an open file with File::SHARE_DELETE" do
path = tmp("share_delete.txt")
File.open(path, mode: File::CREAT | File::WRONLY | File::BINARY | File::SHARE_DELETE) do |f|
- File.exist?(path).should be_true
+ File.should.exist?(path)
File.send(@method, path)
end
- File.exist?(path).should be_false
+ File.should_not.exist?(path)
end
end
end
diff --git a/spec/ruby/core/file/world_readable_spec.rb b/spec/ruby/core/file/world_readable_spec.rb
index 7e6c60b65c..11b8e67d0b 100644
--- a/spec/ruby/core/file/world_readable_spec.rb
+++ b/spec/ruby/core/file/world_readable_spec.rb
@@ -6,7 +6,7 @@ describe "File.world_readable?" do
it "returns nil if the file does not exist" do
file = rand.to_s + $$.to_s
- File.exist?(file).should be_false
+ File.should_not.exist?(file)
File.world_readable?(file).should be_nil
end
end
diff --git a/spec/ruby/core/file/world_writable_spec.rb b/spec/ruby/core/file/world_writable_spec.rb
index 00333a98ab..d378cf2eb9 100644
--- a/spec/ruby/core/file/world_writable_spec.rb
+++ b/spec/ruby/core/file/world_writable_spec.rb
@@ -6,7 +6,7 @@ describe "File.world_writable?" do
it "returns nil if the file does not exist" do
file = rand.to_s + $$.to_s
- File.exist?(file).should be_false
+ File.should_not.exist?(file)
File.world_writable?(file).should be_nil
end
end