1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-09-29 19:13:37 +02:00
parent d51b4e34fb
commit 070cbe22b7
35 changed files with 127 additions and 133 deletions

View file

@ -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