Sha256: 2140df5f9657c48eb515fb96edfdb791c8413fe477564a3028fd99e448fdbf8f

Contents?: true

Size: 1.07 KB

Versions: 21

Compression:

Stored size: 1.07 KB

Contents

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

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

      test 'should read word file' do
        file_path = @permanent_test_files.join('hello_world.doc')
        handler = NdrImport::File::Word.new(file_path, nil)
        handler.tables.each do |tablename, sheet|
          assert_nil tablename
          assert_instance_of Enumerator, sheet
          assert_equal ['Hello world, this is a word document'], sheet.to_a
        end
      end

      test 'should raise exception on invalid word file' do
        assert_raises RuntimeError do
          file_path = @permanent_test_files.join('not_a_word_file.doc')
          handler = NdrImport::File::Word.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

21 entries across 21 versions & 1 rubygems

Version Path
ndr_import-6.1.1 test/file/word_test.rb
ndr_import-6.1.0 test/file/word_test.rb
ndr_import-6.0.0 test/file/word_test.rb
ndr_import-5.1.0 test/file/word_test.rb
ndr_import-5.0.0 test/file/word_test.rb
ndr_import-4.1.4 test/file/word_test.rb
ndr_import-4.1.3 test/file/word_test.rb
ndr_import-4.1.2 test/file/word_test.rb
ndr_import-4.1.1 test/file/word_test.rb
ndr_import-4.1.0 test/file/word_test.rb
ndr_import-4.0.1 test/file/word_test.rb
ndr_import-4.0.0 test/file/word_test.rb
ndr_import-3.1.6 test/file/word_test.rb
ndr_import-3.1.5 test/file/word_test.rb
ndr_import-3.1.4 test/file/word_test.rb
ndr_import-3.1.3 test/file/word_test.rb
ndr_import-3.1.2 test/file/word_test.rb
ndr_import-3.1.1 test/file/word_test.rb
ndr_import-3.1.0 test/file/word_test.rb
ndr_import-3.0.1 test/file/word_test.rb