11require 'docx'
22require 'test/unit'
33
4- class SaveTest < Test ::Unit ::TestCase
4+ class EditTest < Test ::Unit ::TestCase
55 def setup
6- @doc = Docx ::Document . open ( 'test/fixtures/saving .docx' )
6+ @doc = Docx ::Document . open ( 'test/fixtures/editing .docx' )
77 end
88
9- def test_copy
9+ def test_copy_paragraph
1010 old_p = @doc . paragraphs . first
1111 new_p = old_p . copy
1212 assert_kind_of Docx ::Elements ::Containers ::Paragraph , new_p
@@ -15,11 +15,34 @@ def test_copy
1515 end
1616
1717 def test_insertion
18- assert_equal 2 , @doc . paragraphs . size
18+ assert_equal 3 , @doc . paragraphs . size
1919 first_p = @doc . paragraphs . first
2020 new_p = first_p . copy
2121 new_p . insert_after first_p
22- assert_equal 3 , @doc . paragraphs . size
22+ assert_equal 4 , @doc . paragraphs . size
23+ end
24+
25+ def test_paragraph_text
26+ assert_equal 'test text' , @doc . paragraphs . first . text
27+ @doc . paragraphs . first . text = 'the real test'
28+ assert_equal 'the real test' , @doc . paragraphs . first . text
29+ end
30+
31+ def test_inserting_text_before_bookmark
32+ assert_equal 'test text' , @doc . paragraphs . first . text
33+ @doc . bookmarks [ 'beginning_bookmark' ] . insert_text_before ( 'foo' )
34+ assert_equal 'footest text' , @doc . paragraphs . first . text
35+ end
36+
37+ def test_inserting_text_after_bookmark
38+ assert_equal 'test text' , @doc . paragraphs . first . text
39+ @doc . bookmarks [ 'end_bookmark' ] . insert_text_after ( 'bar' )
40+ assert_equal 'test textbar' , @doc . paragraphs . first . text
41+ end
42+
43+ # Insert text intelligently around bookmark
44+ def test_inserting_text_around_bookmark
45+
2346 end
2447
2548 def test_blank
0 commit comments