File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 104104 end
105105 end
106106
107+ ruby_version_is "3.4" do
108+ context "when called with anonymous: true" do
109+ it "returns an already unlinked File without a proper path" do
110+ @tempfile = Tempfile . create ( anonymous : true )
111+ @tempfile . should_not . closed?
112+ @tempfile . path . should == "#{ Dir . tmpdir } /"
113+ File . file? ( @tempfile . path ) . should be_false
114+ end
115+
116+ it "unlinks file before calling the block" do
117+ Tempfile . create ( anonymous : true ) do |tempfile |
118+ @tempfile = tempfile
119+ @tempfile . should_not . closed?
120+ @tempfile . path . should == "#{ Dir . tmpdir } /"
121+ File . file? ( @tempfile . path ) . should be_false
122+ end
123+ @tempfile . should . closed?
124+ end
125+ end
126+
127+ context "when called with anonymous: false" do
128+ it "returns a usual File with a path" do
129+ @tempfile = Tempfile . create ( anonymous : false )
130+ @tempfile . should_not . closed?
131+ @tempfile . path . should . start_with? ( Dir . tmpdir )
132+ File . file? ( @tempfile . path ) . should be_true
133+ end
134+ end
135+ end
136+
107137 context "when called with other options" do
108138 it "passes them along to File.open" do
109139 @tempfile = Tempfile . create ( encoding : "IBM037:IBM037" , binmode : true )
You can’t perform that action at this time.
0 commit comments