Sha256: 8d7eaf583b9c6a712f39356b9ba95ce1b540ee6efa59af9048a6f3d976a20212

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'
require 'ndr_import/file/pdf'

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

      test 'should read pdf correctly' do
        file_path = @permanent_test_files.join('hello_world.pdf')
        handler = NdrImport::File::Pdf.new(file_path, nil)
        handler.tables.each do |tablename, sheet|
          assert_nil tablename
          assert_instance_of Enumerator, sheet
          assert_equal ['Hello World'], sheet.to_a
        end
      end

      test 'should raise exception on invalid pdf file' do
        assert_raises RuntimeError do
          file_path = @permanent_test_files.join('not_a_pdf.pdf')
          handler = NdrImport::File::Pdf.new(file_path, nil)
          handler.tables.each do |tablename, sheet|
            assert_nil tablename
            assert_instance_of Enumerator, sheet
            sheet.to_a
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ndr_import-4.1.4 test/file/pdf_test.rb
ndr_import-4.1.3 test/file/pdf_test.rb
ndr_import-4.1.2 test/file/pdf_test.rb
ndr_import-4.1.1 test/file/pdf_test.rb
ndr_import-4.1.0 test/file/pdf_test.rb
ndr_import-4.0.1 test/file/pdf_test.rb
ndr_import-4.0.0 test/file/pdf_test.rb
ndr_import-3.1.6 test/file/pdf_test.rb
ndr_import-3.1.5 test/file/pdf_test.rb
ndr_import-3.1.4 test/file/pdf_test.rb
ndr_import-3.1.3 test/file/pdf_test.rb
ndr_import-3.1.2 test/file/pdf_test.rb
ndr_import-3.1.1 test/file/pdf_test.rb
ndr_import-3.1.0 test/file/pdf_test.rb
ndr_import-3.0.1 test/file/pdf_test.rb
ndr_import-3.0.0 test/file/pdf_test.rb