File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -535,10 +535,12 @@ def test_streaming
535
535
end
536
536
537
537
data = nil
538
- Zip ::File . open_buffer ( File . binread ( zname ) ) do |zipfile |
539
- zipfile . each do |entry |
540
- next unless entry . name =~ /README.md/
541
- data = zipfile . read ( entry )
538
+ File . open ( zname , 'rb' ) do |f |
539
+ Zip ::File . open_buffer ( f ) do |zipfile |
540
+ zipfile . each do |entry |
541
+ next unless entry . name =~ /README.md/
542
+ data = zipfile . read ( entry )
543
+ end
542
544
end
543
545
end
544
546
assert data
Original file line number Diff line number Diff line change @@ -32,6 +32,21 @@ def test_write_buffer
32
32
assert_test_zip_contents ( TEST_ZIP )
33
33
end
34
34
35
+ def test_write_buffer_with_temp_file
36
+ tmp_file = Tempfile . new ( '' )
37
+
38
+ ::Zip ::OutputStream . write_buffer ( tmp_file ) do |zos |
39
+ zos . comment = TEST_ZIP . comment
40
+ write_test_zip ( zos )
41
+ end
42
+
43
+ tmp_file . rewind
44
+ File . open ( TEST_ZIP . zip_name , 'wb' ) { |f | f . write ( tmp_file . read ) }
45
+ tmp_file . unlink
46
+
47
+ assert_test_zip_contents ( TEST_ZIP )
48
+ end
49
+
35
50
def test_writingToClosedStream
36
51
assert_i_o_error_in_closed_stream { |zos | zos << "hello world" }
37
52
assert_i_o_error_in_closed_stream { |zos | zos . puts "hello world" }
You can’t perform that action at this time.
0 commit comments