Initial project setup
This commit is contained in:
28
test/ezdoc_test.rb
Normal file
28
test/ezdoc_test.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# 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
|
||||
5
test/test_helper.rb
Normal file
5
test/test_helper.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
||||
require "ezdoc"
|
||||
require "minitest/autorun"
|
||||
Reference in New Issue
Block a user