From be5cbe443d7cea3dd7cfc8aec4d984c34a0fb9bf Mon Sep 17 00:00:00 2001 From: Adam Gardiner Date: Wed, 10 Apr 2013 14:29:11 +0100 Subject: Add support for preserving leading and trailing spaces in cell values --- test/workbook/worksheet/tc_cell.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/workbook') diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 208b15e0..9b8cd769 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -275,7 +275,20 @@ class TestCell < Test::Unit::TestCase end doc = Nokogiri::XML(ws.to_xml_string) assert(doc.xpath("//f[@text()='IF(2+2=4,4,5)']")) + end + def test_to_xml_string_with_leading_or_trailing_spaces + # Check that xml:space="preserve" has been added when cell contains leading or trailing spaces + @c.type = :string + @c.value = " a" + c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) + assert(c_xml.xpath("//t/@xml:space='preserve'")) + @c.value = "a " + c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) + assert(c_xml.xpath("//t/@xml:space='preserve'")) + @c.value = "a" + c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) + assert(!c_xml.xpath("//t/@xml:space='preserve'")) end def test_font_size_with_custom_style_and_no_sz -- cgit v1.2.3