From 4194b3c8edfe3429281194d91493d4b251abbd0a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 10 Aug 2016 08:08:47 -0400 Subject: add reader --- spec/zip_spec.cr | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/zip_spec.cr b/spec/zip_spec.cr index a7e306c..7e66518 100644 --- a/spec/zip_spec.cr +++ b/spec/zip_spec.cr @@ -56,9 +56,40 @@ describe Zip::Writer do end describe Zip::Reader do - Zip.read(File.join(TEST_DIR, "test-string.zip")) do |zip| - zip.entries.each do |e| - pp e + it "reads an archive" do + Zip.read(File.join(TEST_DIR, "test-string.zip")) do |zip| + zip.entries.each do |e| + pp e.path + end + end + end + + it "reads an archive created by an external program" do + Zip.read(File.join(TEST_DIR, "real.zip")) do |zip| + zip.each do |e| + pp e.path + end + end + end + + it "reads an archive created by an external program" do + Zip.read(File.join(TEST_DIR, "real.zip")) do |zip| + zip.each do |e| + e.read(File.open("/dev/null", "wb")) + end + end + end + + it "reads all an archive's compressed entries" do + Zip.read(File.join(TEST_DIR, "test-many.zip")) do |zip| + zip.each do |e| + pp e.path + + io = MemoryIO.new + # e.read(STDOUT) + e.read(io) + io.close + end end end end -- cgit v1.2.3