diff options
Diffstat (limited to 'test/workbook/worksheet/tc_comment.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_comment.rb | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb index 8d5df652..9ada0b4e 100644 --- a/test/workbook/worksheet/tc_comment.rb +++ b/test/workbook/worksheet/tc_comment.rb @@ -14,59 +14,63 @@ class TestComment < Test::Unit::TestCase end def test_author - assert(@c1.author == 'author with special char <') - assert(@c2.author == 'PO') + assert_equal('author with special char <', @c1.author) + assert_equal('PO', @c2.author) end def test_text - assert(@c1.text == 'text with special char <') - assert(@c2.text == 'rust bucket') + assert_equal('text with special char <', @c1.text) + assert_equal('rust bucket', @c2.text) end def test_author_index - assert_equal(@c1.author_index, 1) - assert_equal(@c2.author_index, 0) + assert_equal(1, @c1.author_index) + assert_equal(0, @c2.author_index) end def test_visible - assert_equal(false, @c1.visible) - assert_equal(true, @c2.visible) + refute(@c1.visible) + assert(@c2.visible) end def test_ref - assert(@c1.ref == 'A1') - assert(@c2.ref == 'C3') + assert_equal('A1', @c1.ref) + assert_equal('C3', @c2.ref) end def test_vml_shape pos = Axlsx::name_to_indices(@c1.ref) + assert(@c1.vml_shape.is_a?(Axlsx::VmlShape)) - assert(@c1.vml_shape.column == pos[0]) - assert(@c1.vml_shape.row == pos[1]) - assert(@c1.vml_shape.row == pos[1]) + assert_equal(@c1.vml_shape.column, pos[0]) + assert_equal(@c1.vml_shape.row, pos[1]) + assert_equal(@c1.vml_shape.row, pos[1]) assert_equal(pos[0], @c1.vml_shape.left_column) - assert(@c1.vml_shape.top_row == pos[1]) + assert_equal(@c1.vml_shape.top_row, pos[1]) assert_equal(pos[0] + 2, @c1.vml_shape.right_column) - assert(@c1.vml_shape.bottom_row == pos[1] + 4) + assert_equal(@c1.vml_shape.bottom_row, pos[1] + 4) end def test_to_xml_string doc = Nokogiri::XML(@c1.to_xml_string) - assert_equal(doc.xpath("//comment[@ref='#{@c1.ref}']").size, 1) - assert_equal(doc.xpath("//comment[@authorId='#{@c1.author_index}']").size, 1) - assert_equal(doc.xpath("//t[text()='#{@c1.author}:\n']").size, 1) - assert_equal(doc.xpath("//t[text()='#{@c1.text}']").size, 1) + + assert_equal(1, doc.xpath("//comment[@ref='#{@c1.ref}']").size) + assert_equal(1, doc.xpath("//comment[@authorId='#{@c1.author_index}']").size) + assert_equal(1, doc.xpath("//t[text()='#{@c1.author}:\n']").size) + assert_equal(1, doc.xpath("//t[text()='#{@c1.text}']").size) end def test_comment_text_contain_author_and_text comment = @ws.add_comment :ref => 'C4', :text => 'some text', :author => 'Bob' doc = Nokogiri::XML(comment.to_xml_string) + assert_equal("Bob:\nsome text", doc.xpath("//comment/text").text) end def test_comment_text_does_not_contain_stray_colon_if_author_blank comment = @ws.add_comment :ref => 'C5', :text => 'some text', :author => '' doc = Nokogiri::XML(comment.to_xml_string) + assert_equal("some text", doc.xpath("//comment/text").text) end end |
