Skip to content

Commit f7b0740

Browse files
authored
Merge pull request #2119 from ruby/open-file-block
Use `File.open` with block
2 parents e86296d + 59ac47e commit f7b0740

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/stdlib/FileTest_test.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ class FileTestSingletonTest < Test::Unit::TestCase
55

66
testing "singleton(::FileTest)"
77

8-
9-
def with_path_io(path: __FILE__, io: default=File.open(File.expand_path(__FILE__)), &block)
10-
with_path(path, &block)
11-
with_io(io, &block)
12-
ensure
13-
io.close if default
8+
def with_path_io(&block)
9+
with_path(__FILE__, &block)
10+
File.open(File.expand_path(__FILE__)) do |io|
11+
with_io(io, &block)
12+
end
1413
end
1514

1615
def test_blockdev?

0 commit comments

Comments
 (0)