Sha256: 0f12e384880e076329f6b3d785c6a4f86481fe196b779ea1eca482d68692e859
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require 'test_helper' require 'ndr_import/file/docx' module NdrImport module File # Word .docx document file handler tests class DocxTest < 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.docx') handler = NdrImport::File::Docx.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 modern word document', 'With more than one line of text', 'Three in fact' ], sheet.to_a end end test 'should read password protected word file' do file_path = @permanent_test_files.join('password_protected_hello_world.docx') handler = NdrImport::File::Docx.new(file_path, nil, file_password: 'salad') handler.tables.each do |tablename, sheet| assert_nil tablename assert_instance_of Enumerator, sheet assert_equal [ 'Hello world, this is a modern word document', 'With more than one line of text', 'Three in fact' ], 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.docx') handler = NdrImport::File::Docx.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ndr_import-8.5.0 | test/file/docx_test.rb |