From 7db5855fa050a18fad0de842f6cb04a71398bbb7 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 12 Aug 2012 23:24:45 +0900 Subject: finish specs for worksheet hyperlink to_xml_string --- test/workbook/worksheet/tc_worksheet_hyperlink.rb | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index 1d9b4e20..6c2b1003 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -37,12 +37,23 @@ class TestWorksheetHyperlink < Test::Unit::TestCase end - def test_to_xml_string - doc = Nokogiri::XML(@a.to_xml_string) - # TODO find a way to add in the namespace or test this in worksheet as r (relation) namespace is not defined - # assert_equal(doc.xpath("//hyperlink[@ref='#{@a.ref}']").size, 1) - # assert_equal(doc.xpath("//hyperlink[@tooltip='#{@a.tooltip}']").size, 1) - # assert_equal(doc.xpath("//hyperlink[@display='#{@a.display}']").size, 1) + def test_to_xml_string_with_non_external + doc = Nokogiri::XML(@ws.to_xml_string) + assert_equal(doc.xpath("//xmlns:hyperlink[@ref='#{@a.ref}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@tooltip='#{@a.tooltip}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@location='#{@a.location}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@display='#{@a.display}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@r:id='#{@a.id}']").size, 0) + end + + def test_to_xml_stirng_with_external + @a.target = :external + doc = Nokogiri::XML(@ws.to_xml_string) + assert_equal(doc.xpath("//xmlns:hyperlink[@ref='#{@a.ref}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@tooltip='#{@a.tooltip}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@display='#{@a.display}']").size, 1) + assert_equal(doc.xpath("//xmlns:hyperlink[@location='#{@a.location}']").size, 0) + assert_equal(doc.xpath("//xmlns:hyperlink[@r:id='#{@a.id}']").size, 1) end end -- cgit v1.2.3