summaryrefslogtreecommitdiffhomepage
path: root/test/workbook
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-09-29 13:14:53 +0900
committerRandy Morgan <[email protected]>2013-09-29 13:14:53 +0900
commit097b7da7eb6b29907da28c174e83ff22a6358176 (patch)
tree152f5bf7c0a85568eb1beb230290d397cc103af0 /test/workbook
parent90fcca29df390de244e2b16ef0279fd373482981 (diff)
downloadcaxlsx-097b7da7eb6b29907da28c174e83ff22a6358176.tar.gz
caxlsx-097b7da7eb6b29907da28c174e83ff22a6358176.zip
Added workbook views collection and workbook view object
Diffstat (limited to 'test/workbook')
-rw-r--r--test/workbook/tc_workbook_view.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/workbook/tc_workbook_view.rb b/test/workbook/tc_workbook_view.rb
new file mode 100644
index 00000000..73f39a9c
--- /dev/null
+++ b/test/workbook/tc_workbook_view.rb
@@ -0,0 +1,47 @@
+require 'tc_helper'
+
+class TestWorkbookView < Test::Unit::TestCase
+
+ def setup
+ @options = { visibility: :hidden, minimized: true, show_horizontal_scroll: true, show_vertical_scroll: true,
+ show_sheet_tabs: true, tab_ratio: 750, first_sheet: 0, active_tab: 1, x_window: 500, y_window: 400,
+ window_width: 800, window_height: 600, auto_filter_date_grouping: true }
+ @book_view = Axlsx::WorkbookView.new @options
+ end
+
+ def test_options_assignation
+ @options.each do |key, value|
+ assert_equal(value, @book_view.send(key))
+ end
+ end
+
+ def test_boolean_attribute_validation
+ %w(minimized show_horizontal_scroll show_vertical_scroll show_sheet_tabs auto_filter_date_grouping).each do |attr|
+ assert_raise(ArgumentError, 'only booleanish allowed in boolean attributes') { @book_view.send("#{attr}=", "banana") }
+ assert_nothing_raised { @book_view.send("#{attr}=", false )}
+ end
+ end
+
+ def test_integer_attribute_validation
+ %w(tab_ratio first_sheet active_tab x_window y_window window_width window_height).each do |attr|
+ assert_raise(ArgumentError, 'only integer allowed in integer attributes') { @book_view.send("#{attr}=", "b") }
+ assert_nothing_raised { @book_view.send("#{attr}=", 7 )}
+ end
+ end
+
+ def test_visibility_attribute_validation
+ assert_raise(ArgumentError) { @book_view.visibility = :foobar }
+ assert_nothing_raised { @book_view.visibility = :hidden }
+ assert_nothing_raised { @book_view.visibility = :very_hidden }
+ assert_nothing_raised { @book_view.visibility = :visible }
+ end
+
+ def test_to_xml_string
+ xml = @book_view.to_xml_string
+ doc = Nokogiri::XML(xml)
+ @options.each do |key, value|
+ path = "workbookView[@#{Axlsx.camel(key, false)}='#{value}']"
+ assert_equal(1, doc.xpath(path).size)
+ end
+ end
+end