diff options
| author | Ryan Winograd <[email protected]> | 2020-08-13 21:05:59 -0500 |
|---|---|---|
| committer | Ryan Winograd <[email protected]> | 2020-08-19 14:59:17 -0500 |
| commit | e7673f431813cde7aab2d032a4417d4ddeeb9342 (patch) | |
| tree | 95d2758cd969c9c4b7c3d38a887ae75a65185f7e /test/tc_package.rb | |
| parent | 33a53474a90f1825ce20c66dab481fdcfa1106bf (diff) | |
| download | caxlsx-e7673f431813cde7aab2d032a4417d4ddeeb9342.tar.gz caxlsx-e7673f431813cde7aab2d032a4417d4ddeeb9342.zip | |
Add option to `#serialize` with system zip command
Add a `:zip_command` option to `Axlsx::Package#serialize` that allows
the user to specify an alternate command to use to perform the zip
operation on the XLSX file contents.
The default zip operation is provided by RubyZip. On large documents
users may experience faster zip times using a zip binary.
Resolves #55
Diffstat (limited to 'test/tc_package.rb')
| -rw-r--r-- | test/tc_package.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/test/tc_package.rb b/test/tc_package.rb index 23078862..18c08f5c 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -128,11 +128,34 @@ class TestPackage < Test::Unit::TestCase def test_serialization @package.serialize(@fname) - zf = Zip::File.open(@fname) - @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) } + assert_zip_file_matches_package(@fname, @package) File.delete(@fname) end + def test_serialization_with_zip_command + @package.serialize(@fname, false, zip_command: "zip") + assert_zip_file_matches_package(@fname, @package) + File.delete(@fname) + end + + def test_serialization_with_zip_command_and_absolute_path + fname = "#{Dir.tmpdir}/#{@fname}" + @package.serialize(fname, false, zip_command: "zip") + assert_zip_file_matches_package(fname, @package) + File.delete(fname) + end + + def test_serialization_with_invalid_zip_command + assert_raises Axlsx::ZipCommand::ZipError do + @package.serialize(@fname, false, zip_command: "invalid_zip") + end + end + + def assert_zip_file_matches_package(fname, package) + zf = Zip::File.open(fname) + package.send(:parts).each{ |part| zf.get_entry(part[:entry]) } + end + # See comment for Package#zip_entry_for_part def test_serialization_creates_identical_files_at_any_time_if_created_at_is_set @package.core.created = Time.now |
