Skip to content

Commit

Permalink
Merge pull request #2119 from ruby/open-file-block
Browse files Browse the repository at this point in the history
Use `File.open` with block
  • Loading branch information
soutaro authored Dec 5, 2024
2 parents e86296d + 59ac47e commit f7b0740
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/stdlib/FileTest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ class FileTestSingletonTest < Test::Unit::TestCase

testing "singleton(::FileTest)"


def with_path_io(path: __FILE__, io: default=File.open(File.expand_path(__FILE__)), &block)
with_path(path, &block)
with_io(io, &block)
ensure
io.close if default
def with_path_io(&block)
with_path(__FILE__, &block)
File.open(File.expand_path(__FILE__)) do |io|
with_io(io, &block)
end
end

def test_blockdev?
Expand Down

0 comments on commit f7b0740

Please sign in to comment.