Skip to content

Commit

Permalink
Add spec for IO::FileDescriptor#finalize flushes
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Aug 8, 2024
1 parent 94bdba1 commit 8eb3e48
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions spec/std/io/file_descriptor_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,31 @@ describe IO::FileDescriptor do
end
end

it "closes on finalize" do
pipes = [] of IO::FileDescriptor
assert_finalizes("fd") do
a, b = IO.pipe
pipes << b
a
describe "#finalize" do
it "closes" do
pipes = [] of IO::FileDescriptor
assert_finalizes("fd") do
a, b = IO.pipe
pipes << b
a
end

expect_raises(IO::Error) do
pipes.each do |p|
p.puts "123"
end
end
end

expect_raises(IO::Error) do
pipes.each do |p|
p.puts "123"
it "flushes" do
with_tempfile "fd-finalize-flush" do |path|
file = File.new(path, "w")
file << "foo"
file.flush
file << "bar"
file.finalize

File.read(path).should eq "foobar"
end
end
end
Expand Down

0 comments on commit 8eb3e48

Please sign in to comment.