Project rename
All checks were successful
CI Pipeline / build (push) Successful in 12s

This commit is contained in:
2025-12-02 13:21:13 +01:00
parent 29ebb9a8d1
commit dec346254c
36 changed files with 114 additions and 114 deletions

View File

@@ -3,11 +3,11 @@
require "test_helper"
class DocumentTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_creates_valid_docx_structure
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) do |doc|
Notare::Document.create(file.path) do |doc|
doc.p "Test"
end
@@ -33,7 +33,7 @@ class DocumentTest < Minitest::Test
def test_empty_document
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) { |_doc| } # rubocop:disable Lint/EmptyBlock
Notare::Document.create(file.path) { |_doc| } # rubocop:disable Lint/EmptyBlock
assert File.exist?(file.path)
Zip::File.open(file.path) do |zip|
@@ -45,30 +45,30 @@ class DocumentTest < Minitest::Test
def test_document_create_returns_document
result = nil
Tempfile.create(["test", ".docx"]) do |file|
result = Ezdoc::Document.create(file.path) do |doc|
result = Notare::Document.create(file.path) do |doc|
doc.p "Test"
end
end
assert_instance_of Ezdoc::Document, result
assert_instance_of Notare::Document, result
end
def test_document_has_nodes
doc = Ezdoc::Document.new
doc = Notare::Document.new
doc.p "Test"
assert_equal 1, doc.nodes.count
assert_instance_of Ezdoc::Nodes::Paragraph, doc.nodes.first
assert_instance_of Notare::Nodes::Paragraph, doc.nodes.first
end
def test_document_lists_helper
doc = Ezdoc::Document.new
doc = Notare::Document.new
doc.p "Paragraph"
doc.ul { doc.li "Bullet" }
doc.ol { doc.li "Number" }
doc.table { doc.tr { doc.td "Cell" } }
assert_equal 2, doc.lists.count
assert(doc.lists.all? { |l| l.is_a?(Ezdoc::Nodes::List) })
assert(doc.lists.all? { |l| l.is_a?(Notare::Nodes::List) })
end
end

View File

@@ -3,7 +3,7 @@
require "test_helper"
class FormattingTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_bold_text
xml = create_doc_and_read_xml do |doc|

View File

@@ -3,7 +3,7 @@
require "test_helper"
class HeadingTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_h1
xml = create_doc_and_read_xml { |doc| doc.h1 "Title" }

View File

@@ -3,7 +3,7 @@
require "test_helper"
class ImageTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def setup
@png_path = File.expand_path("fixtures/test.png", __dir__)
@@ -80,7 +80,7 @@ class ImageTest < Minitest::Test
def test_image_file_embedded_in_docx
files = nil
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) do |doc|
Notare::Document.create(file.path) do |doc|
doc.p { doc.image @png_path }
end
Zip::File.open(file.path) do |zip|
@@ -124,7 +124,7 @@ class ImageTest < Minitest::Test
def test_invalid_image_path_raises_error
assert_raises(ArgumentError) do
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) do |doc|
Notare::Document.create(file.path) do |doc|
doc.p { doc.image "/nonexistent/image.png" }
end
end
@@ -138,7 +138,7 @@ class ImageTest < Minitest::Test
assert_raises(ArgumentError) do
Tempfile.create(["test", ".docx"]) do |docx_file|
Ezdoc::Document.create(docx_file.path) do |doc|
Notare::Document.create(docx_file.path) do |doc|
doc.p { doc.image gif_file.path }
end
end
@@ -149,7 +149,7 @@ class ImageTest < Minitest::Test
def test_same_image_used_multiple_times_deduplication
files = nil
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) do |doc|
Notare::Document.create(file.path) do |doc|
doc.p { doc.image @png_path }
doc.p { doc.image @png_path }
doc.p { doc.image @png_path }
@@ -166,7 +166,7 @@ class ImageTest < Minitest::Test
def test_multiple_different_images
files = nil
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) do |doc|
Notare::Document.create(file.path) do |doc|
doc.p { doc.image @png_path }
doc.p { doc.image @jpeg_path }
end

View File

@@ -3,7 +3,7 @@
require "test_helper"
class IntegrationTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_complex_document_with_all_features
xml_files = create_doc_and_read_all_xml do |doc|

View File

@@ -3,7 +3,7 @@
require "test_helper"
class ListTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
#
# Bullet List Tests

View File

@@ -3,7 +3,7 @@
require "test_helper"
class ParagraphTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_simple_paragraph
xml = create_doc_and_read_xml { |doc| doc.p "Hello World" }

View File

@@ -3,7 +3,7 @@
require "test_helper"
class StyleTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_define_custom_style
xml_files = create_doc_and_read_all_xml do |doc|
@@ -124,7 +124,7 @@ class StyleTest < Minitest::Test
def test_unknown_style_raises_error
assert_raises(ArgumentError) do
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path) do |doc|
Notare::Document.create(file.path) do |doc|
doc.p "Test", style: :nonexistent
end
end
@@ -133,18 +133,18 @@ class StyleTest < Minitest::Test
def test_invalid_color_raises_error
assert_raises(ArgumentError) do
Ezdoc::Style.new(:bad, color: "invalid")
Notare::Style.new(:bad, color: "invalid")
end
end
def test_invalid_alignment_raises_error
assert_raises(ArgumentError) do
Ezdoc::Style.new(:bad, align: :invalid)
Notare::Style.new(:bad, align: :invalid)
end
end
def test_color_normalizes_hash
style = Ezdoc::Style.new(:test, color: "#ff0000")
style = Notare::Style.new(:test, color: "#ff0000")
assert_equal "FF0000", style.color
end

View File

@@ -3,7 +3,7 @@
require "test_helper"
class TableTest < Minitest::Test
include EzdocTestHelpers
include NotareTestHelpers
def test_simple_table
xml = create_doc_and_read_xml do |doc|

View File

@@ -1,17 +1,17 @@
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "ezdoc"
require "notare"
require "minitest/autorun"
require "tempfile"
require "zip"
module EzdocTestHelpers
module NotareTestHelpers
# Helper to create a document and return the document.xml content
def create_doc_and_read_xml(&block)
content = nil
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path, &block)
Notare::Document.create(file.path, &block)
Zip::File.open(file.path) do |zip|
content = zip.read("word/document.xml").force_encoding("UTF-8")
end
@@ -23,7 +23,7 @@ module EzdocTestHelpers
def create_doc_and_read_all_xml(&block)
result = {}
Tempfile.create(["test", ".docx"]) do |file|
Ezdoc::Document.create(file.path, &block)
Notare::Document.create(file.path, &block)
Zip::File.open(file.path) do |zip|
zip.each do |entry|
if entry.name.end_with?(".xml") || entry.name.end_with?(".rels")