Sha256: 91b8c681d28a16f627c84c99415a15be08be05aab5c9ea4f2ef1da2503567afb
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require 'tc_helper.rb' class TestComments < Test::Unit::TestCase def setup p = Axlsx::Package.new wb = p.workbook @ws = wb.add_worksheet @c1 = @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank' @c2 = @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO' end def test_initialize assert_raise(ArgumentError) { Axlsx::Comments.new } assert(@ws.comments.vml_drawing.is_a?(Axlsx::VmlDrawing)) end def test_add_comment assert_equal(@ws.comments.size, 2) assert_raise(ArgumentError) { @ws.comments.add_comment() } assert_raise(ArgumentError) { @ws.comments.add_comment(:text => 'Yes We Can', :ref => 'A1') } assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :ref => 'A1') } assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can')} assert_nothing_raised { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can', :ref => 'A1') } assert_equal(@ws.comments.size, 3) end def test_authors assert_equal(@ws.comments.authors.size, @ws.comments.size) @ws.add_comment(:text => 'Yes We Can!', :author => :bob, :ref => 'F1') assert_equal(@ws.comments.authors.size, 3) @ws.add_comment(:text => 'Yes We Can!', :author => :bob, :ref => 'F1') assert_equal(@ws.comments.authors.size, 3, 'only unique authors are returned') end def test_pn assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index+1).to_s) end def test_index assert_equal(@ws.index, @ws.comments.index) end def test_to_xml_string doc = Nokogiri::XML(@ws.comments.to_xml_string) # puts doc.xpath("comments").to_xml # TODO figure out why these xpath expressions dont work! # assert(doc.xpath("//comments")) # assert_equal(doc.xpath("//xmlns:author").size, @ws.comments.authors.size) # assert_equal(doc.xpath("//comment").size, @ws.comments.size) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axlsx-1.1.5 | test/workbook/worksheet/tc_comments.rb |