29 lines
774 B
Ruby
29 lines
774 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
require "tempfile"
|
|
require "zip"
|
|
|
|
class EzdocTest < Minitest::Test
|
|
def test_creates_valid_docx_with_hello_world
|
|
Tempfile.create(["test", ".docx"]) do |file|
|
|
Ezdoc::Document.create(file.path) do |doc|
|
|
doc.text "Hello World"
|
|
end
|
|
|
|
assert File.exist?(file.path)
|
|
assert File.size(file.path).positive?
|
|
|
|
Zip::File.open(file.path) do |zip|
|
|
assert zip.find_entry("[Content_Types].xml")
|
|
assert zip.find_entry("_rels/.rels")
|
|
assert zip.find_entry("word/document.xml")
|
|
assert zip.find_entry("word/_rels/document.xml.rels")
|
|
|
|
document_xml = zip.read("word/document.xml")
|
|
assert_includes document_xml, "Hello World"
|
|
end
|
|
end
|
|
end
|
|
end
|