diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-08-29 12:17:07 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-08-29 12:23:23 +0200 |
commit | e8c3872555fc85640505974e6b1c39d315572689 (patch) | |
tree | d3efaa93985db2932c57d15729d18e3c0e1ca2d6 /test/rdoc | |
parent | ff323b2a5c56cdec93900af4d67f3811f946d9b8 (diff) |
Simplify Tempfile.open calls with a block as they now unlink the file automatically
Diffstat (limited to 'test/rdoc')
-rw-r--r-- | test/rdoc/test_rdoc_parser.rb | 4 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_rd_block_parser.rb | 4 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_rdoc.rb | 12 |
3 files changed, 5 insertions, 15 deletions
diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index 7cc3c2d926..cd43aca121 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -106,7 +106,7 @@ class TestRDocParser < RDoc::TestCase def test_class_for_forbidden omit 'chmod not supported' if Gem.win_platform? - tf = Tempfile.open 'forbidden' do |io| + Tempfile.open 'forbidden' do |io| begin File.chmod 0000, io.path forbidden = @store.add_file io.path @@ -117,9 +117,7 @@ class TestRDocParser < RDoc::TestCase ensure File.chmod 0400, io.path end - io end - tf.close! end def test_class_for_modeline diff --git a/test/rdoc/test_rdoc_rd_block_parser.rb b/test/rdoc/test_rdoc_rd_block_parser.rb index 22f432eaf4..24413ee8e8 100644 --- a/test/rdoc/test_rdoc_rd_block_parser.rb +++ b/test/rdoc/test_rdoc_rd_block_parser.rb @@ -154,7 +154,7 @@ class TestRDocRdBlockParser < RDoc::TestCase blank_line, blank_line) - tf = Tempfile.open %w[parse_include .rd] do |io| + Tempfile.open %w[parse_include .rd] do |io| io.puts "=begin\ninclude ((*worked*))\n=end" io.flush @@ -163,9 +163,7 @@ class TestRDocRdBlockParser < RDoc::TestCase STR assert_equal expected, parse(str) - io end - tf.close! end def test_parse_heading diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index f2cc901283..782409987a 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -342,16 +342,14 @@ class TestRDocRDoc < RDoc::TestCase @rdoc.options.encoding = Encoding::ISO_8859_1 @rdoc.store = RDoc::Store.new - tf = Tempfile.open 'test.txt' do |io| + Tempfile.open 'test.txt' do |io| io.write 'hi' io.rewind top_level = @rdoc.parse_file io.path assert_equal Encoding::ISO_8859_1, top_level.absolute_name.encoding - io end - tf.close! end def test_parse_file_forbidden @@ -360,7 +358,7 @@ class TestRDocRDoc < RDoc::TestCase @rdoc.store = RDoc::Store.new - tf = Tempfile.open 'test.txt' do |io| + Tempfile.open 'test.txt' do |io| io.write 'hi' io.rewind @@ -379,9 +377,7 @@ class TestRDocRDoc < RDoc::TestCase ensure File.chmod 0400, io.path end - io end - tf.close! end def test_remove_unparseable @@ -478,7 +474,7 @@ class TestRDocRDoc < RDoc::TestCase end def test_setup_output_dir_exists_file - tf = Tempfile.open 'test_rdoc_rdoc' do |tempfile| + Tempfile.open 'test_rdoc_rdoc' do |tempfile| path = tempfile.path e = assert_raise RDoc::Error do @@ -487,9 +483,7 @@ class TestRDocRDoc < RDoc::TestCase assert_match(%r%#{Regexp.escape path} exists and is not a directory%, e.message) - tempfile end - tf.close! end def test_setup_output_dir_exists_not_rdoc |