diff --git a/test/error_highlight/test_error_highlight.rb b/test/error_highlight/test_error_highlight.rb index dcc8ce4eaf..27a34ed2f4 100644 --- a/test/error_highlight/test_error_highlight.rb +++ b/test/error_highlight/test_error_highlight.rb @@ -1002,34 +1002,36 @@ undefined method `time' for 1:Integer end def test_hard_tabs - tmp = Tempfile.new(["error_highlight_test", ".rb"], binmode: true) - tmp << "\t \t1.time {}\n" - tmp.close(false) + Tempfile.create(["error_highlight_test", ".rb"], binmode: true) do |tmp| + tmp << "\t \t1.time {}\n" + tmp.close - assert_error_message(NoMethodError, <<~END.gsub("_", "\t")) do + assert_error_message(NoMethodError, <<~END.gsub("_", "\t")) do undefined method `time' for 1:Integer _ _1.time {} _ _ ^^^^^ END - load tmp.path + load tmp.path + end end end def test_no_final_newline - tmp = Tempfile.new(["error_highlight_test", ".rb"]) - tmp << "1.time {}" - tmp.close(false) + Tempfile.create(["error_highlight_test", ".rb"]) do |tmp| + tmp << "1.time {}" + tmp.close - assert_error_message(NoMethodError, <<~END) do + assert_error_message(NoMethodError, <<~END) do undefined method `time' for 1:Integer 1.time {} ^^^^^ END - load tmp.path + load tmp.path + end end end end