From 1860ad00a2c26ceaeaec100e8fe114f69fe50810 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 13 Jul 2025 23:22:03 +1200 Subject: [PATCH] Don't leak Tempfile instances. --- fixtures/async/http/a_protocol.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fixtures/async/http/a_protocol.rb b/fixtures/async/http/a_protocol.rb index c20a7def..5fadf4e6 100644 --- a/fixtures/async/http/a_protocol.rb +++ b/fixtures/async/http/a_protocol.rb @@ -301,13 +301,11 @@ def endpoint_options expect(response.body.length).not.to be_nil end - let(:tempfile) {Tempfile.new} - it "can save to disk" do - response.save(tempfile.path) - expect(tempfile.read).to be == expected - - tempfile.close + Tempfile.open do |tempfile| + response.save(tempfile.path) + expect(tempfile.read).to be == expected + end end it "has response header" do