adds delegetion for eof? to AD::Http::UploadedFile

if you want to read the file you may need to ask if there is something
to read from
This commit is contained in:
Jens Fahnenbruck 2011-08-23 21:10:01 +02:00 committed by Piotr Sarnacki
parent e96d04a2e4
commit 96b72efc00
2 changed files with 7 additions and 1 deletions

@ -17,7 +17,7 @@ def read(*args)
end
# Delegate these methods to the tempfile.
[:open, :path, :rewind, :size].each do |method|
[:open, :path, :rewind, :size, :eof?].each do |method|
class_eval "def #{method}; @tempfile.#{method}; end"
end

@ -65,6 +65,12 @@ def test_delegate_respects_respond_to?
end
end
def test_delegate_eof_to_tempfile
tf = Class.new { def eof?; true end; }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert uf.eof?
end
def test_respond_to?
tf = Class.new { def read; yield end }
uf = Http::UploadedFile.new(:tempfile => tf.new)