diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-08-06 20:37:46 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-08-06 20:37:46 -0400 |
commit | b1a21248d2e71ec4741d1df66d4fd15a5e3b13d1 (patch) | |
tree | 72ee3a2f00014fb46b7de0cd7f015ef51bd841c2 /spec | |
parent | 0584c5d628f34b5d2edb2a075774e0d457423bd2 (diff) | |
download | zip-crystal-b1a21248d2e71ec4741d1df66d4fd15a5e3b13d1.tar.bz2 zip-crystal-b1a21248d2e71ec4741d1df66d4fd15a5e3b13d1.zip |
add additional tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/zip_spec.cr | 35 |
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 |