summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-04-28 12:55:46 +0900
committerRandy Morgan <[email protected]>2013-04-28 12:55:46 +0900
commite49aee3e2f700569a519c5346746d239a05383cf (patch)
tree7f449191165a3fbdf05b34c4239dda6ec179d033 /test
parenta120fdb2e787986ced4952b6ef3f4b70056960d9 (diff)
downloadcaxlsx-e49aee3e2f700569a519c5346746d239a05383cf.tar.gz
caxlsx-e49aee3e2f700569a519c5346746d239a05383cf.zip
Refactored and renamed space preservation
preserve_spaces has been moved to the workbook and renamed xml_space as that provides a good reference for people trying to figure out what it does, and let's the author specify space preservation for serializations using the shared strings table as well as the default inline serialization in cells.
Diffstat (limited to 'test')
-rw-r--r--test/workbook/tc_shared_strings_table.rb6
-rw-r--r--test/workbook/tc_workbook.rb17
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb9
3 files changed, 23 insertions, 9 deletions
diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb
index e3c9bf7b..7a333f4f 100644
--- a/test/workbook/tc_shared_strings_table.rb
+++ b/test/workbook/tc_shared_strings_table.rb
@@ -24,6 +24,12 @@ class TestSharedStringsTable < Test::Unit::TestCase
assert_equal(sst.unique_count, 4)
end
+ def test_uses_workbook_xml_space
+ assert_equal(@p.workbook.xml_space, @p.workbook.shared_strings.xml_space)
+ @p.workbook.xml_space = :default
+ assert_equal(:default, @p.workbook.shared_strings.xml_space)
+ end
+
def test_valid_document
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
doc = Nokogiri::XML(@p.workbook.shared_strings.to_xml_string)
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index 1a9b9669..591160f4 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -9,6 +9,23 @@ class TestWorkbook < Test::Unit::TestCase
def teardown
end
+ def test_worksheet_users_xml_space
+ sheet = @wb.add_worksheet(:name => 'foo')
+ ws_xml = Nokogiri::XML(sheet.to_xml_string)
+ assert(ws_xml.xpath("//xmlns:worksheet/@xml:space='preserve'"))
+
+ @wb.xml_space = :default
+ ws_xml = Nokogiri::XML(sheet.to_xml_string)
+ assert(ws_xml.xpath("//xmlns:worksheet/@xml:space='default'"))
+ end
+
+ def test_xml_space
+ assert_equal(:preserve, @wb.xml_space)
+ @wb.xml_space = :default
+ assert_equal(:default, @wb.xml_space)
+ assert_raise(ArgumentError) { @wb.xml_space = :none }
+ end
+
def test_no_autowidth
assert_equal(@wb.use_autowidth, true)
assert_raise(ArgumentError) {@wb.use_autowidth = 0.1}
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index c2bb0faa..ed8c7cab 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -352,15 +352,6 @@ class TestWorksheet < Test::Unit::TestCase
assert(schema.validate(doc).map{ |e| puts e.message; e }.empty?, "error free validation")
end
- def test_to_xml_string_with_preserve_spaces
- # Check that xml:space="preserve" has been added when preserve_spaces is set
- ws_xml = Nokogiri::XML(@ws.to_xml_string)
- assert(ws_xml.xpath("//xmlns:worksheet/@xml:space='preserve'"))
- @ws.preserve_spaces = false
- ws_xml = Nokogiri::XML(@ws.to_xml_string)
- assert(!ws_xml.xpath("//xmlns:worksheet/@xml:space='preserve'"))
- end
-
def test_styles
assert(@ws.styles.is_a?(Axlsx::Styles), 'worksheet provides access to styles')
end