1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/error_highlight] Fix leaked tempfiles

https://github.com/ruby/error_highlight/commit/8b353a10a7
This commit is contained in:
Nobuyoshi Nakada 2021-07-15 21:08:57 +09:00
parent 6073a8bdc0
commit 29ed9d1aaa

View file

@ -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