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

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