Merge pull request #353 from pnomolos/pnomolos/fix_stringio
Added fix for calling 'close' on a StringIO-backed zip file, and specs
This commit is contained in:
commit
05af1231f4
|
@ -306,7 +306,7 @@ module Zip
|
|||
# Commits changes that has been made since the previous commit to
|
||||
# the zip archive.
|
||||
def commit
|
||||
return unless commit_required?
|
||||
return if name.is_a?(StringIO) || !commit_required?
|
||||
on_success_replace do |tmp_file|
|
||||
::Zip::OutputStream.open(tmp_file) do |zos|
|
||||
@entry_set.each do |e|
|
||||
|
|
|
@ -104,6 +104,19 @@ class ZipFileTest < MiniTest::Test
|
|||
end
|
||||
end
|
||||
|
||||
def test_close_buffer_with_stringio
|
||||
string_io = StringIO.new File.read('test/data/rubycode.zip')
|
||||
zf = ::Zip::File.open_buffer string_io
|
||||
assert(zf.close || true) # Poor man's refute_raises
|
||||
end
|
||||
|
||||
def test_close_buffer_with_io
|
||||
f = File.open('test/data/rubycode.zip')
|
||||
zf = ::Zip::File.open_buffer f
|
||||
assert zf.close
|
||||
f.close
|
||||
end
|
||||
|
||||
def test_open_buffer_without_block
|
||||
string_io = StringIO.new File.read('test/data/rubycode.zip')
|
||||
zf = ::Zip::File.open_buffer string_io
|
||||
|
|
Loading…
Reference in New Issue