neocities/tests/tempfile_tests.rb
Kyle Drake e52aa29290 Fix tempfile returning nil for empty files
This is an "monkey patch" to have Tempfile return 0 instead of nil when
a tempfile is empty. This has caused an unexplained exception in our
logs for years, and I was really surprised when I caught it, and more
surprised that nobody has ever reported it to us before.

I really think this is a bug, and have filed it as a bug on the ruby
tracker. I haven't seen any consequences (yet) to doing this, so I'm
just going to run with it and see what happens. If it blows
something up (how? what scenario?), I'll try a different approach.
2017-02-06 11:26:14 -08:00

10 lines
198 B
Ruby

require_relative './environment.rb'
describe Tempfile do
it 'should return 0 when no data is written' do
tmp = Tempfile.new
tmp.write ''
tmp.close
tmp.size.must_equal 0
end
end