Sha256: 7c58a7d79ddedc391a69e46950172d23827e2c95e5dad1823077f0b275ede4ae

Contents?: true

Size: 1.37 KB

Versions: 32

Compression:

Stored size: 1.37 KB

Contents

require 'test_helper'
require 'ndr_import/file/zip'
require 'zip'

module NdrImport
  module File
    # Zip file handler tests
    class ZipTest < ActiveSupport::TestCase
      def setup
        @home = SafePath.new('test_space_rw')
        @permanent_test_files = SafePath.new('permanent_test_files')
      end

      test 'should reject non SafePath arguments' do
        file_path = @home.join('imaginary.zip')

        assert_raises ArgumentError do
          NdrImport::File::Zip.new(file_path.to_s, nil, 'unzip_path' => @home.to_s)
        end

        assert_raises ArgumentError do
          NdrImport::File::Zip.new(file_path.to_s, nil, 'unzip_path' => @home)
        end

        assert_raises ArgumentError do
          NdrImport::File::Zip.new(file_path, nil, 'unzip_path' => @home.to_s)
        end
      end

      test 'should read table correctly' do
        options = { 'unzip_path' => @home }
        file_path = @permanent_test_files.join('normal.csv.zip')

        handler = NdrImport::File::Zip.new(file_path, nil, options)
        handler.files.each do |filename|
          assert_instance_of SafePath, filename
          assert_equal 'normal.csv', ::File.basename(filename)
        end

        exception = assert_raises RuntimeError do
          handler.tables
        end
        assert_equal 'Zip#tables should never be called', exception.message
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ndr_import-8.5.0 test/file/zip_test.rb
ndr_import-8.4.0 test/file/zip_test.rb
ndr_import-8.3.0 test/file/zip_test.rb
ndr_import-8.2.0 test/file/zip_test.rb
ndr_import-8.1.0 test/file/zip_test.rb
ndr_import-8.0.0 test/file/zip_test.rb
ndr_import-7.0.0 test/file/zip_test.rb
ndr_import-6.4.1 test/file/zip_test.rb
ndr_import-6.4.0 test/file/zip_test.rb
ndr_import-6.3.0 test/file/zip_test.rb
ndr_import-6.2.0 test/file/zip_test.rb
ndr_import-6.1.1 test/file/zip_test.rb
ndr_import-6.1.0 test/file/zip_test.rb
ndr_import-6.0.0 test/file/zip_test.rb
ndr_import-5.1.0 test/file/zip_test.rb
ndr_import-5.0.0 test/file/zip_test.rb
ndr_import-4.1.4 test/file/zip_test.rb
ndr_import-4.1.3 test/file/zip_test.rb
ndr_import-4.1.2 test/file/zip_test.rb
ndr_import-4.1.1 test/file/zip_test.rb