summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-08-06 20:37:46 -0400
committerPaul Duncan <pabs@pablotron.org>2016-08-06 20:37:46 -0400
commitb1a21248d2e71ec4741d1df66d4fd15a5e3b13d1 (patch)
tree72ee3a2f00014fb46b7de0cd7f015ef51bd841c2
parent0584c5d628f34b5d2edb2a075774e0d457423bd2 (diff)
downloadzip-crystal-b1a21248d2e71ec4741d1df66d4fd15a5e3b13d1.tar.bz2
zip-crystal-b1a21248d2e71ec4741d1df66d4fd15a5e3b13d1.zip
add additional tests
-rw-r--r--spec/zip_spec.cr35
1 files changed, 31 insertions, 4 deletions
diff --git a/spec/zip_spec.cr b/spec/zip_spec.cr
index 0ace290..d132c1c 100644
--- a/spec/zip_spec.cr
+++ b/spec/zip_spec.cr
@@ -1,6 +1,7 @@
require "./spec_helper"
TEST_DIR = File.dirname(__FILE__)
+TEST_FILE_PATH = File.join(TEST_DIR, "..", "shard.yml")
describe Zip do
# TODO: Write tests
@@ -11,9 +12,35 @@ describe Zip do
end
describe Zip::Writer do
- Zip.write(File.join(TEST_DIR, "test.zip")) do |zip|
- zip.add("foo.txt", MemoryIO.new("foo"))
- zip.add("bar.txt", "bar")
- zip.add_file("shard.yml", File.join(TEST_DIR, "..", "shard.yml"))
+ it "creates an empty archive" do
+ Zip.write(File.join(TEST_DIR, "test-empty.zip")) do |zip|
+ # do nothing
+ end
+ end
+
+ it "creates an entry from a String" do
+ Zip.write(File.join(TEST_DIR, "test-string.zip")) do |zip|
+ zip.add("bar.txt", "bar")
+ end
+ end
+
+ it "creates an entry from a MemoryIO" do
+ Zip.write(File.join(TEST_DIR, "test-memio.zip")) do |zip|
+ zip.add("bar.txt", "bar")
+ end
+ end
+
+ it "creates an entry from a File" do
+ Zip.write(File.join(TEST_DIR, "test-file.zip")) do |zip|
+ zip.add_file("shard.yml", TEST_FILE_PATH)
+ end
+ end
+
+ it "creates an archive from a MemoryIO, String, and File" do
+ Zip.write(File.join(TEST_DIR, "test-many.zip")) do |zip|
+ zip.add("foo.txt", MemoryIO.new("foo"))
+ zip.add("bar.txt", "bar")
+ zip.add_file("shard.yml", TEST_FILE_PATH)
+ end
end
end