summaryrefslogtreecommitdiffhomepage
path: root/test/workbook
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-05-22 20:13:13 +0200
committerGeremia Taglialatela <[email protected]>2023-05-22 20:13:13 +0200
commit083c4c6d62011cd88966d608b0c6bb736f300a0c (patch)
treeb5ceb9b3a32c4130d84c3075966b4033bf32a118 /test/workbook
parent6752225bbb8a9eec905ec02a98f1a25a309c404a (diff)
downloadcaxlsx-083c4c6d62011cd88966d608b0c6bb736f300a0c.tar.gz
caxlsx-083c4c6d62011cd88966d608b0c6bb736f300a0c.zip
Use Ruby 1.9 hash syntax (non-production code)
Diffstat (limited to 'test/workbook')
-rw-r--r--test/workbook/tc_shared_strings_table.rb4
-rw-r--r--test/workbook/tc_workbook.rb28
-rw-r--r--test/workbook/worksheet/auto_filter/tc_auto_filter.rb2
-rw-r--r--test/workbook/worksheet/auto_filter/tc_filter_column.rb2
-rw-r--r--test/workbook/worksheet/auto_filter/tc_filters.rb6
-rw-r--r--test/workbook/worksheet/tc_break.rb12
-rw-r--r--test/workbook/worksheet/tc_cell.rb14
-rw-r--r--test/workbook/worksheet/tc_cfvo.rb2
-rw-r--r--test/workbook/worksheet/tc_col.rb2
-rw-r--r--test/workbook/worksheet/tc_color_scale.rb6
-rw-r--r--test/workbook/worksheet/tc_comment.rb8
-rw-r--r--test/workbook/worksheet/tc_comments.rb16
-rw-r--r--test/workbook/worksheet/tc_conditional_formatting.rb52
-rw-r--r--test/workbook/worksheet/tc_data_bar.rb4
-rw-r--r--test/workbook/worksheet/tc_data_validation.rb60
-rw-r--r--test/workbook/worksheet/tc_header_footer.rb56
-rw-r--r--test/workbook/worksheet/tc_outline_pr.rb2
-rw-r--r--test/workbook/worksheet/tc_page_margins.rb8
-rw-r--r--test/workbook/worksheet/tc_page_set_up_pr.rb2
-rw-r--r--test/workbook/worksheet/tc_page_setup.rb36
-rw-r--r--test/workbook/worksheet/tc_pane.rb6
-rw-r--r--test/workbook/worksheet/tc_pivot_table.rb20
-rw-r--r--test/workbook/worksheet/tc_print_options.rb10
-rw-r--r--test/workbook/worksheet/tc_protected_range.rb2
-rw-r--r--test/workbook/worksheet/tc_rich_text.rb12
-rw-r--r--test/workbook/worksheet/tc_rich_text_run.rb16
-rw-r--r--test/workbook/worksheet/tc_row.rb8
-rw-r--r--test/workbook/worksheet/tc_selection.rb12
-rw-r--r--test/workbook/worksheet/tc_sheet_calc_pr.rb2
-rw-r--r--test/workbook/worksheet/tc_sheet_format_pr.rb18
-rw-r--r--test/workbook/worksheet/tc_sheet_pr.rb20
-rw-r--r--test/workbook/worksheet/tc_sheet_protection.rb10
-rw-r--r--test/workbook/worksheet/tc_sheet_view.rb22
-rw-r--r--test/workbook/worksheet/tc_table.rb4
-rw-r--r--test/workbook/worksheet/tc_table_style_info.rb12
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb38
-rw-r--r--test/workbook/worksheet/tc_worksheet_hyperlink.rb2
37 files changed, 268 insertions, 268 deletions
diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb
index 4aa308f1..2edf5f4a 100644
--- a/test/workbook/tc_shared_strings_table.rb
+++ b/test/workbook/tc_shared_strings_table.rb
@@ -4,13 +4,13 @@ require 'tc_helper'
class TestSharedStringsTable < Test::Unit::TestCase
def setup
- @p = Axlsx::Package.new :use_shared_strings => true
+ @p = Axlsx::Package.new use_shared_strings: true
ws = @p.workbook.add_worksheet
ws.add_row ['a', 1, 'b']
ws.add_row ['b', 1, 'c']
ws.add_row ['c', 1, 'd']
- ws.rows.last.add_cell('b', :type => :text)
+ ws.rows.last.add_cell('b', type: :text)
end
def test_workbook_has_shared_strings
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index b1cfdc71..51fe3976 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -11,7 +11,7 @@ class TestWorkbook < Test::Unit::TestCase
def teardown; end
def test_worksheet_users_xml_space
- sheet = @wb.add_worksheet(:name => 'foo')
+ sheet = @wb.add_worksheet(name: 'foo')
ws_xml = Nokogiri::XML(sheet.to_xml_string)
assert(ws_xml.xpath("//xmlns:worksheet/@xml:space='preserve'"))
@@ -45,16 +45,16 @@ class TestWorkbook < Test::Unit::TestCase
end
def test_sheet_by_name_retrieval
- @wb.add_worksheet(:name => 'foo')
- @wb.add_worksheet(:name => 'bar')
- @wb.add_worksheet(:name => "testin'")
+ @wb.add_worksheet(name: 'foo')
+ @wb.add_worksheet(name: 'bar')
+ @wb.add_worksheet(name: "testin'")
assert_equal('foo', @wb.sheet_by_name('foo').name)
assert_equal("testin&apos;", @wb.sheet_by_name("testin'").name)
end
def test_worksheet_empty_name
- assert_raise(ArgumentError) { @wb.add_worksheet(:name => '') }
+ assert_raise(ArgumentError) { @wb.add_worksheet(name: '') }
end
def test_date1904
@@ -68,7 +68,7 @@ class TestWorkbook < Test::Unit::TestCase
end
def test_add_defined_name
- @wb.add_defined_name 'Sheet1!1:1', :name => '_xlnm.Print_Titles', :hidden => true
+ @wb.add_defined_name 'Sheet1!1:1', name: '_xlnm.Print_Titles', hidden: true
assert_equal(1, @wb.defined_names.size)
end
@@ -87,7 +87,7 @@ class TestWorkbook < Test::Unit::TestCase
def test_add_worksheet
assert_empty(@wb.worksheets, "worbook has no worksheets by default")
- ws = @wb.add_worksheet(:name => "bob")
+ ws = @wb.add_worksheet(name: "bob")
assert_equal(1, @wb.worksheets.size, "add_worksheet adds a worksheet!")
assert_equal(@wb.worksheets.first, ws, "the worksheet returned is the worksheet added")
@@ -95,9 +95,9 @@ class TestWorkbook < Test::Unit::TestCase
end
def test_insert_worksheet
- @wb.add_worksheet(:name => 'A')
- @wb.add_worksheet(:name => 'B')
- ws3 = @wb.insert_worksheet(0, :name => 'C')
+ @wb.add_worksheet(name: 'A')
+ @wb.add_worksheet(name: 'B')
+ ws3 = @wb.insert_worksheet(0, name: 'C')
assert_equal(ws3.name, @wb.worksheets.first.name)
end
@@ -127,15 +127,15 @@ class TestWorkbook < Test::Unit::TestCase
def test_to_xml_reversed
@wb.is_reversed = true
- @wb.add_worksheet(:name => 'first')
- second = @wb.add_worksheet(:name => 'second')
+ @wb.add_worksheet(name: 'first')
+ second = @wb.add_worksheet(name: 'second')
doc = Nokogiri::XML(@wb.to_xml_string)
assert_equal second.name, doc.xpath('//xmlns:workbook/xmlns:sheets/*[1]/@name').to_s
end
def test_range_requires_valid_sheet
- ws = @wb.add_worksheet :name => 'fish'
+ ws = @wb.add_worksheet name: 'fish'
ws.add_row [1, 2, 3]
ws.add_row [4, 5, 6]
assert_raise(ArgumentError, "no sheet name part") { @wb["A1:C2"] }
@@ -178,7 +178,7 @@ class TestWorkbook < Test::Unit::TestCase
end
def test_worksheet_name_is_intact_after_serialized_into_xml
- sheet = @wb.add_worksheet(:name => '_Example')
+ sheet = @wb.add_worksheet(name: '_Example')
wb_xml = Nokogiri::XML(@wb.to_xml_string)
assert_equal sheet.name, wb_xml.xpath('//xmlns:workbook/xmlns:sheets/*[1]/@name').to_s
diff --git a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
index 85ba32b7..cb8b34fa 100644
--- a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
+++ b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
@@ -8,7 +8,7 @@ class TestAutoFilter < Test::Unit::TestCase
3.times { |index| ws.add_row [1 * index, 2 * index, 3 * index] }
@auto_filter = ws.auto_filter
@auto_filter.range = 'A1:C3'
- @auto_filter.add_column 0, :filters, :filter_items => [1]
+ @auto_filter.add_column 0, :filters, filter_items: [1]
end
def test_defined_name
diff --git a/test/workbook/worksheet/auto_filter/tc_filter_column.rb b/test/workbook/worksheet/auto_filter/tc_filter_column.rb
index d89446c6..b98314cb 100644
--- a/test/workbook/worksheet/auto_filter/tc_filter_column.rb
+++ b/test/workbook/worksheet/auto_filter/tc_filter_column.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestFilterColumn < Test::Unit::TestCase
def setup
- @filter_column = Axlsx::FilterColumn.new(0, :filters, :filter_items => [200])
+ @filter_column = Axlsx::FilterColumn.new(0, :filters, filter_items: [200])
end
def test_initialize_col_id
diff --git a/test/workbook/worksheet/auto_filter/tc_filters.rb b/test/workbook/worksheet/auto_filter/tc_filters.rb
index 4cd8ca00..fc1b5c21 100644
--- a/test/workbook/worksheet/auto_filter/tc_filters.rb
+++ b/test/workbook/worksheet/auto_filter/tc_filters.rb
@@ -4,9 +4,9 @@ require 'tc_helper'
class TestFilters < Test::Unit::TestCase
def setup
- @filters = Axlsx::Filters.new(:filter_items => [1, 'a'],
- :date_group_items => [{ :date_time_grouping => :year, :year => 2011, :month => 11, :day => 11, :hour => 0, :minute => 0, :second => 0 }],
- :blank => true)
+ @filters = Axlsx::Filters.new(filter_items: [1, 'a'],
+ date_group_items: [{ date_time_grouping: :year, year: 2011, month: 11, day: 11, hour: 0, minute: 0, second: 0 }],
+ blank: true)
end
def test_blank
diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb
index a441abe0..32cc2864 100644
--- a/test/workbook/worksheet/tc_break.rb
+++ b/test/workbook/worksheet/tc_break.rb
@@ -4,41 +4,41 @@ require 'tc_helper'
class TestBreak < Test::Unit::TestCase
def setup
- @break = Axlsx::Break.new(:id => 1, :min => 1, :max => 10, :man => true, :pt => false)
+ @break = Axlsx::Break.new(id: 1, min: 1, max: 10, man: true, pt: false)
end
def test_id
assert_equal(1, @break.id)
assert_raises ArgumentError do
- Axlsx::Break.new(:hoge, { :id => -1 })
+ Axlsx::Break.new(:hoge, { id: -1 })
end
end
def test_min
assert_equal(1, @break.min)
assert_raises ArgumentError do
- Axlsx::Break.new(:hoge, :min => -1)
+ Axlsx::Break.new(:hoge, min: -1)
end
end
def test_max
assert_equal(10, @break.max)
assert_raises ArgumentError do
- Axlsx::Break.new(:hoge, :max => -1)
+ Axlsx::Break.new(:hoge, max: -1)
end
end
def test_man
assert(@break.man)
assert_raises ArgumentError do
- Axlsx::Break.new(:man => -1)
+ Axlsx::Break.new(man: -1)
end
end
def test_pt
refute(@break.pt)
assert_raises ArgumentError do
- Axlsx::Break.new(:pt => -1)
+ Axlsx::Break.new(pt: -1)
end
end
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index fef23ede..a8ab6ca1 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -6,10 +6,10 @@ class TestCell < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
p.use_shared_strings = true
- @ws = p.workbook.add_worksheet :name => "hmmm"
- p.workbook.styles.add_style :sz => 20
+ @ws = p.workbook.add_worksheet name: "hmmm"
+ p.workbook.styles.add_style sz: 20
@row = @ws.add_row
- @c = @row.add_cell 1, :type => :float, :style => 1, :escape_formulas => true
+ @c = @row.add_cell 1, type: :float, style: 1, escape_formulas: true
data = (0..26).map { |index| index }
@ws.add_row data
@cAA = @ws["AA2"]
@@ -62,7 +62,7 @@ class TestCell < Test::Unit::TestCase
end
def test_autowidth
- style = @c.row.worksheet.workbook.styles.add_style({ :alignment => { :horizontal => :center, :vertical => :center, :wrap_text => true } })
+ style = @c.row.worksheet.workbook.styles.add_style({ alignment: { horizontal: :center, vertical: :center, wrap_text: true } })
@c.style = style
assert_in_delta(6.6, @c.autowidth, 0.01)
@@ -539,20 +539,20 @@ class TestCell < Test::Unit::TestCase
end
def test_font_size_with_custom_style_and_no_sz
- @c.style = @c.row.worksheet.workbook.styles.add_style :bg_color => 'FF00FF'
+ @c.style = @c.row.worksheet.workbook.styles.add_style bg_color: 'FF00FF'
sz = @c.send(:font_size)
assert_equal(sz, @c.row.worksheet.workbook.styles.fonts.first.sz)
end
def test_font_size_with_bolding
- @c.style = @c.row.worksheet.workbook.styles.add_style :b => true
+ @c.style = @c.row.worksheet.workbook.styles.add_style b: true
assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @c.send(:font_size))
end
def test_font_size_with_custom_sz
- @c.style = @c.row.worksheet.workbook.styles.add_style :sz => 52
+ @c.style = @c.row.worksheet.workbook.styles.add_style sz: 52
sz = @c.send(:font_size)
assert_equal(52, sz)
diff --git a/test/workbook/worksheet/tc_cfvo.rb b/test/workbook/worksheet/tc_cfvo.rb
index 0e2e5332..dac48b23 100644
--- a/test/workbook/worksheet/tc_cfvo.rb
+++ b/test/workbook/worksheet/tc_cfvo.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestCfvo < Test::Unit::TestCase
def setup
- @cfvo = Axlsx::Cfvo.new(:val => "0", :type => :min)
+ @cfvo = Axlsx::Cfvo.new(val: "0", type: :min)
end
def test_val
diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb
index e795c301..c20d32be 100644
--- a/test/workbook/worksheet/tc_col.rb
+++ b/test/workbook/worksheet/tc_col.rb
@@ -8,7 +8,7 @@ class TestCol < Test::Unit::TestCase
end
def test_initialize
- options = { :width => 12, :collapsed => true, :hidden => true, :outline_level => 1, :phonetic => true, :style => 1 }
+ options = { width: 12, collapsed: true, hidden: true, outline_level: 1, phonetic: true, style: 1 }
col = Axlsx::Col.new 0, 0, options
diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb
index 335e8057..b4720e3e 100644
--- a/test/workbook/worksheet/tc_color_scale.rb
+++ b/test/workbook/worksheet/tc_color_scale.rb
@@ -35,7 +35,7 @@ class TestColorScale < Test::Unit::TestCase
end
def test_partial_default_cfvo_override
- first_def = { :type => :percent, :val => "10.0", :color => 'FF00FF00' }
+ first_def = { type: :percent, val: "10.0", color: 'FF00FF00' }
color_scale = Axlsx::ColorScale.new(first_def)
assert_equal color_scale.value_objects.first.val, first_def[:val]
@@ -44,14 +44,14 @@ class TestColorScale < Test::Unit::TestCase
end
def test_add
- @color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE"
+ @color_scale.add type: :max, val: 5, color: "FFDEDEDE"
assert_equal(3, @color_scale.value_objects.size)
assert_equal(3, @color_scale.colors.size)
end
def test_delete_at
- @color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE"
+ @color_scale.add type: :max, val: 5, color: "FFDEDEDE"
assert_nothing_raised { @color_scale.delete_at 2 }
assert_equal(2, @color_scale.value_objects.size)
assert_equal(2, @color_scale.colors.size)
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb
index 65b2ca1d..aa33dba4 100644
--- a/test/workbook/worksheet/tc_comment.rb
+++ b/test/workbook/worksheet/tc_comment.rb
@@ -7,8 +7,8 @@ class TestComment < Test::Unit::TestCase
p = Axlsx::Package.new
wb = p.workbook
@ws = wb.add_worksheet
- @c1 = @ws.add_comment :ref => 'A1', :text => 'text with special char <', :author => 'author with special char <', :visible => false
- @c2 = @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO'
+ @c1 = @ws.add_comment ref: 'A1', text: 'text with special char <', author: 'author with special char <', visible: false
+ @c2 = @ws.add_comment ref: 'C3', text: 'rust bucket', author: 'PO'
end
def test_initailize
@@ -63,14 +63,14 @@ class TestComment < Test::Unit::TestCase
end
def test_comment_text_contain_author_and_text
- comment = @ws.add_comment :ref => 'C4', :text => 'some text', :author => 'Bob'
+ comment = @ws.add_comment ref: 'C4', text: 'some text', author: 'Bob'
doc = Nokogiri::XML(comment.to_xml_string)
assert_equal("Bob:\nsome text", doc.xpath("//comment/text").text)
end
def test_comment_text_does_not_contain_stray_colon_if_author_blank
- comment = @ws.add_comment :ref => 'C5', :text => 'some text', :author => ''
+ comment = @ws.add_comment ref: 'C5', text: 'some text', author: ''
doc = Nokogiri::XML(comment.to_xml_string)
assert_equal("some text", doc.xpath("//comment/text").text)
diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb
index 445f2342..d9be807e 100644
--- a/test/workbook/worksheet/tc_comments.rb
+++ b/test/workbook/worksheet/tc_comments.rb
@@ -7,8 +7,8 @@ class TestComments < Test::Unit::TestCase
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'
+ @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
@@ -19,19 +19,19 @@ class TestComments < Test::Unit::TestCase
def test_add_comment
assert_equal(2, @ws.comments.size)
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_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(3, @ws.comments.size)
end
def test_authors
assert_equal(@ws.comments.authors.size, @ws.comments.size)
- @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1')
+ @ws.add_comment(text: 'Yes We Can!', author: 'bob', ref: 'F1')
assert_equal(3, @ws.comments.authors.size)
- @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1')
+ @ws.add_comment(text: 'Yes We Can!', author: 'bob', ref: 'F1')
assert_equal(3, @ws.comments.authors.size, 'only unique authors are returned')
end
diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb
index f706dae3..104ce456 100644
--- a/test/workbook/worksheet/tc_conditional_formatting.rb
+++ b/test/workbook/worksheet/tc_conditional_formatting.rb
@@ -5,14 +5,14 @@ require 'tc_helper'
class TestConditionalFormatting < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "hmmm"
- @cfs = @ws.add_conditional_formatting("A1:A1", [{ :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :greaterThan, :formula => "0.5" }])
+ @ws = p.workbook.add_worksheet name: "hmmm"
+ @cfs = @ws.add_conditional_formatting("A1:A1", [{ type: :cellIs, dxfId: 0, priority: 1, operator: :greaterThan, formula: "0.5" }])
@cf = @cfs.first
@cfr = @cf.rules.first
end
def test_initialize_with_options
- optioned = Axlsx::ConditionalFormatting.new(:sqref => "AA1:AB100", :rules => [1, 2])
+ optioned = Axlsx::ConditionalFormatting.new(sqref: "AA1:AB100", rules: [1, 2])
assert_equal("AA1:AB100", optioned.sqref)
assert_equal([1, 2], optioned.rules)
@@ -26,14 +26,14 @@ class TestConditionalFormatting < Test::Unit::TestCase
cs.value_objects.first.val = 5
end
- data_bar = Axlsx::DataBar.new :color => "FFFF0000"
- icon_set = Axlsx::IconSet.new :iconSet => "5Rating"
- cfr = Axlsx::ConditionalFormattingRule.new({ :type => :containsText, :text => "TRUE",
- :dxfId => 0, :priority => 1,
- :formula => 'NOT(ISERROR(SEARCH("FALSE",AB1)))',
- :color_scale => color_scale,
- :data_bar => data_bar,
- :icon_set => icon_set })
+ data_bar = Axlsx::DataBar.new color: "FFFF0000"
+ icon_set = Axlsx::IconSet.new iconSet: "5Rating"
+ cfr = Axlsx::ConditionalFormattingRule.new({ type: :containsText, text: "TRUE",
+ dxfId: 0, priority: 1,
+ formula: 'NOT(ISERROR(SEARCH("FALSE",AB1)))',
+ color_scale: color_scale,
+ data_bar: data_bar,
+ icon_set: icon_set })
assert(cfr.data_bar.is_a?(Axlsx::DataBar))
assert(cfr.icon_set.is_a?(Axlsx::IconSet))
@@ -72,15 +72,15 @@ class TestConditionalFormatting < Test::Unit::TestCase
cs.value_objects.first.val = 5
end
- data_bar = Axlsx::DataBar.new :color => "FFFF0000"
- icon_set = Axlsx::IconSet.new :iconSet => "5Rating"
+ data_bar = Axlsx::DataBar.new color: "FFFF0000"
+ icon_set = Axlsx::IconSet.new iconSet: "5Rating"
- cfs = @ws.add_conditional_formatting("B2:B2", [{ :type => :containsText, :text => "TRUE",
- :dxfId => 0, :priority => 1,
- :formula => 'NOT(ISERROR(SEARCH("FALSE",AB1)))',
- :color_scale => color_scale,
- :data_bar => data_bar,
- :icon_set => icon_set }])
+ cfs = @ws.add_conditional_formatting("B2:B2", [{ type: :containsText, text: "TRUE",
+ dxfId: 0, priority: 1,
+ formula: 'NOT(ISERROR(SEARCH("FALSE",AB1)))',
+ color_scale: color_scale,
+ data_bar: data_bar,
+ icon_set: icon_set }])
doc = Nokogiri::XML.parse(cfs.last.to_xml_string)
assert_equal(1, doc.xpath(".//conditionalFormatting[@sqref='B2:B2']//cfRule[@type='containsText'][@dxfId=0][@priority=1]").size)
@@ -114,11 +114,11 @@ class TestConditionalFormatting < Test::Unit::TestCase
end
def test_many_options
- cf = Axlsx::ConditionalFormatting.new(:sqref => "B3:B4")
- cf.add_rule({ :type => :cellIs, :aboveAverage => false, :bottom => false, :dxfId => 0,
- :equalAverage => false, :priority => 2, :operator => :lessThan, :text => "",
- :percent => false, :rank => 0, :stdDev => 1, :stopIfTrue => true, :timePeriod => :today,
- :formula => "0.0" })
+ cf = Axlsx::ConditionalFormatting.new(sqref: "B3:B4")
+ cf.add_rule({ type: :cellIs, aboveAverage: false, bottom: false, dxfId: 0,
+ equalAverage: false, priority: 2, operator: :lessThan, text: "",
+ percent: false, rank: 0, stdDev: 1, stopIfTrue: true, timePeriod: :today,
+ formula: "0.0" })
doc = Nokogiri::XML.parse(cf.to_xml_string)
assert_equal(1, doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=0][@bottom=0][@dxfId=0][@equalAverage=0][@priority=2][@operator='lessThan'][@text=''][@percent=0][@rank=0][@stdDev=1][@stopIfTrue=1][@timePeriod='today']").size)
@@ -133,7 +133,7 @@ class TestConditionalFormatting < Test::Unit::TestCase
end
def test_multiple_formats
- @ws.add_conditional_formatting "B3:B3", { :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :greaterThan, :formula => "1" }
+ @ws.add_conditional_formatting "B3:B3", { type: :cellIs, dxfId: 0, priority: 1, operator: :greaterThan, formula: "1" }
doc = Nokogiri::XML.parse(@ws.to_xml_string)
assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='greaterThan']//xmlns:formula='1'")
@@ -141,7 +141,7 @@ class TestConditionalFormatting < Test::Unit::TestCase
end
def test_multiple_formulas
- @ws.add_conditional_formatting "B3:B3", { :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :between, :formula => ["1 <> 2", "5"] }
+ @ws.add_conditional_formatting "B3:B3", { type: :cellIs, dxfId: 0, priority: 1, operator: :between, formula: ["1 <> 2", "5"] }
doc = Nokogiri::XML.parse(@ws.to_xml_string)
assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='between']//xmlns:formula='1 <> 2'")
diff --git a/test/workbook/worksheet/tc_data_bar.rb b/test/workbook/worksheet/tc_data_bar.rb
index 62c6fc34..03af393b 100644
--- a/test/workbook/worksheet/tc_data_bar.rb
+++ b/test/workbook/worksheet/tc_data_bar.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestDataBar < Test::Unit::TestCase
def setup
- @data_bar = Axlsx::DataBar.new :color => "FF638EC6"
+ @data_bar = Axlsx::DataBar.new color: "FF638EC6"
end
def test_defaults
@@ -14,7 +14,7 @@ class TestDataBar < Test::Unit::TestCase
end
def test_override_default_cfvos
- data_bar = Axlsx::DataBar.new({ :color => 'FF00FF00' }, { :type => :min, :val => "20" })
+ data_bar = Axlsx::DataBar.new({ color: 'FF00FF00' }, { type: :min, val: "20" })
assert_equal("20", data_bar.value_objects.first.val)
assert_equal("0", data_bar.value_objects.last.val)
diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb
index 4be68673..fa09b0ab 100644
--- a/test/workbook/worksheet/tc_data_validation.rb
+++ b/test/workbook/worksheet/tc_data_validation.rb
@@ -8,13 +8,13 @@ class TestDataValidation < Test::Unit::TestCase
def setup
# inverse defaults
- @boolean_options = { :allowBlank => false, :hideDropDown => true, :showErrorMessage => false, :showInputMessage => true }
- @nil_options = { :formula1 => 'foo', :formula2 => 'foo', :errorTitle => 'foo', :operator => :lessThan, :prompt => 'foo', :promptTitle => 'foo', :sqref => 'foo' }
- @type_option = { :type => :whole }
- @error_style_option = { :errorStyle => :warning }
+ @boolean_options = { allowBlank: false, hideDropDown: true, showErrorMessage: false, showInputMessage: true }
+ @nil_options = { formula1: 'foo', formula2: 'foo', errorTitle: 'foo', operator: :lessThan, prompt: 'foo', promptTitle: 'foo', sqref: 'foo' }
+ @type_option = { type: :whole }
+ @error_style_option = { errorStyle: :warning }
- @string_options = { :formula1 => 'foo', :formula2 => 'foo', :error => 'foo', :errorTitle => 'foo', :prompt => 'foo', :promptTitle => 'foo', :sqref => 'foo' }
- @symbol_options = { :errorStyle => :warning, :operator => :lessThan, :type => :whole }
+ @string_options = { formula1: 'foo', formula2: 'foo', error: 'foo', errorTitle: 'foo', prompt: 'foo', promptTitle: 'foo', sqref: 'foo' }
+ @symbol_options = { errorStyle: :warning, operator: :lessThan, type: :whole }
@options = @boolean_options.merge(@nil_options).merge(@type_option).merge(@error_style_option)
@@ -165,11 +165,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_whole_decimal_data_time_textLength_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "data_validation"
- @ws.add_data_validation("A1", { :type => :whole, :operator => :between, :formula1 => '5', :formula2 => '10',
- :showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values between 5 and 10',
- :errorStyle => :information, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values between 5 and 10' })
+ @ws = p.workbook.add_worksheet name: "data_validation"
+ @ws.add_data_validation("A1", { type: :whole, operator: :between, formula1: '5', formula2: '10',
+ showErrorMessage: true, errorTitle: 'Wrong input', error: 'Only values between 5 and 10',
+ errorStyle: :information, showInputMessage: true, promptTitle: 'Be carful!',
+ prompt: 'Only values between 5 and 10' })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -194,11 +194,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_list_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "data_validation"
- @ws.add_data_validation("A1", { :type => :list, :formula1 => 'A1:A5',
- :showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values from list',
- :errorStyle => :stop, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values from list', :hideDropDown => true })
+ @ws = p.workbook.add_worksheet name: "data_validation"
+ @ws.add_data_validation("A1", { type: :list, formula1: 'A1:A5',
+ showErrorMessage: true, errorTitle: 'Wrong input', error: 'Only values from list',
+ errorStyle: :stop, showInputMessage: true, promptTitle: 'Be carful!',
+ prompt: 'Only values from list', hideDropDown: true })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -218,11 +218,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_custom_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "data_validation"
- @ws.add_data_validation("A1", { :type => :custom, :formula1 => '=5/2',
- :showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values corresponding formula',
- :errorStyle => :stop, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values corresponding formula' })
+ @ws = p.workbook.add_worksheet name: "data_validation"
+ @ws.add_data_validation("A1", { type: :custom, formula1: '=5/2',
+ showErrorMessage: true, errorTitle: 'Wrong input', error: 'Only values corresponding formula',
+ errorStyle: :stop, showInputMessage: true, promptTitle: 'Be carful!',
+ prompt: 'Only values corresponding formula' })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -241,15 +241,15 @@ class TestDataValidation < Test::Unit::TestCase
def test_multiple_datavalidations_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "data_validation"
- @ws.add_data_validation("A1", { :type => :whole, :operator => :between, :formula1 => '5', :formula2 => '10',
- :showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values between 5 and 10',
- :errorStyle => :information, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values between 5 and 10' })
- @ws.add_data_validation("B1", { :type => :list, :formula1 => 'A1:A5',
- :showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values from list',
- :errorStyle => :stop, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values from list', :hideDropDown => true })
+ @ws = p.workbook.add_worksheet name: "data_validation"
+ @ws.add_data_validation("A1", { type: :whole, operator: :between, formula1: '5', formula2: '10',
+ showErrorMessage: true, errorTitle: 'Wrong input', error: 'Only values between 5 and 10',
+ errorStyle: :information, showInputMessage: true, promptTitle: 'Be carful!',
+ prompt: 'Only values between 5 and 10' })
+ @ws.add_data_validation("B1", { type: :list, formula1: 'A1:A5',
+ showErrorMessage: true, errorTitle: 'Wrong input', error: 'Only values from list',
+ errorStyle: :stop, showInputMessage: true, promptTitle: 'Be carful!',
+ prompt: 'Only values from list', hideDropDown: true })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
diff --git a/test/workbook/worksheet/tc_header_footer.rb b/test/workbook/worksheet/tc_header_footer.rb
index 8a62b281..d5c7651c 100644
--- a/test/workbook/worksheet/tc_header_footer.rb
+++ b/test/workbook/worksheet/tc_header_footer.rb
@@ -5,7 +5,7 @@ require 'tc_helper'
class TestHeaderFooter < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
- ws = @p.workbook.add_worksheet :name => 'test'
+ ws = @p.workbook.add_worksheet name: 'test'
@hf = ws.header_footer
end
@@ -25,19 +25,19 @@ class TestHeaderFooter < Test::Unit::TestCase
def test_initialize_with_options
header_footer = {
- :odd_header => 'oh',
- :odd_footer => 'of',
+ odd_header: 'oh',
+ odd_footer: 'of',
- :even_header => 'eh',
- :even_footer => 'ef',
+ even_header: 'eh',
+ even_footer: 'ef',
- :first_header => 'fh',
- :first_footer => 'ff',
+ first_header: 'fh',
+ first_footer: 'ff',
- :different_first => true,
- :different_odd_even => true
+ different_first: true,
+ different_odd_even: true
}
- optioned = @p.workbook.add_worksheet(:name => 'optioned', :header_footer => header_footer).header_footer
+ optioned = @p.workbook.add_worksheet(name: 'optioned', header_footer: header_footer).header_footer
assert_equal('oh', optioned.odd_header)
assert_equal('of', optioned.odd_footer)
@@ -68,17 +68,17 @@ class TestHeaderFooter < Test::Unit::TestCase
def test_set_all_values
@hf.set(
- :odd_header => 'oh',
- :odd_footer => 'of',
+ odd_header: 'oh',
+ odd_footer: 'of',
- :even_header => 'eh',
- :even_footer => 'ef',
+ even_header: 'eh',
+ even_footer: 'ef',
- :first_header => 'fh',
- :first_footer => 'ff',
+ first_header: 'fh',
+ first_footer: 'ff',
- :different_first => true,
- :different_odd_even => true
+ different_first: true,
+ different_odd_even: true
)
assert_equal('oh', @hf.odd_header)
@@ -96,17 +96,17 @@ class TestHeaderFooter < Test::Unit::TestCase
def test_to_xml_all_values
@hf.set(
- :odd_header => 'oh',
- :odd_footer => 'of',
+ odd_header: 'oh',
+ odd_footer: 'of',
- :even_header => 'eh',
- :even_footer => 'ef',
+ even_header: 'eh',
+ even_footer: 'ef',
- :first_header => 'fh',
- :first_footer => 'ff',
+ first_header: 'fh',
+ first_footer: 'ff',
- :different_first => true,
- :different_odd_even => true
+ different_first: true,
+ different_odd_even: true
)
doc = Nokogiri::XML.parse(@hf.to_xml_string)
@@ -131,8 +131,8 @@ class TestHeaderFooter < Test::Unit::TestCase
def test_to_xml_some_values
@hf.set(
- :odd_header => 'oh',
- :different_odd_even => false
+ odd_header: 'oh',
+ different_odd_even: false
)
doc = Nokogiri::XML.parse(@hf.to_xml_string)
diff --git a/test/workbook/worksheet/tc_outline_pr.rb b/test/workbook/worksheet/tc_outline_pr.rb
index 95b52530..7c3769c9 100644
--- a/test/workbook/worksheet/tc_outline_pr.rb
+++ b/test/workbook/worksheet/tc_outline_pr.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestOutlinePr < Test::Unit::TestCase
def setup
- @outline_pr = Axlsx::OutlinePr.new(:summary_below => false, :summary_right => true, :apply_styles => false)
+ @outline_pr = Axlsx::OutlinePr.new(summary_below: false, summary_right: true, apply_styles: false)
end
def test_summary_below
diff --git a/test/workbook/worksheet/tc_page_margins.rb b/test/workbook/worksheet/tc_page_margins.rb
index 8c580204..39f51fec 100644
--- a/test/workbook/worksheet/tc_page_margins.rb
+++ b/test/workbook/worksheet/tc_page_margins.rb
@@ -5,7 +5,7 @@ require 'tc_helper'
class TestPageMargins < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- ws = p.workbook.add_worksheet :name => "hmmm"
+ ws = p.workbook.add_worksheet name: "hmmm"
@pm = ws.page_margins
end
@@ -19,7 +19,7 @@ class TestPageMargins < Test::Unit::TestCase
end
def test_initialize_with_options
- optioned = Axlsx::PageMargins.new(:left => 2, :right => 3, :top => 2, :bottom => 1, :header => 0.1, :footer => 0.1)
+ optioned = Axlsx::PageMargins.new(left: 2, right: 3, top: 2, bottom: 1, header: 0.1, footer: 0.1)
assert_equal(2, optioned.left)
assert_equal(3, optioned.right)
@@ -30,7 +30,7 @@ class TestPageMargins < Test::Unit::TestCase
end
def test_set_all_values
- @pm.set(:left => 1.1, :right => 1.2, :top => 1.3, :bottom => 1.4, :header => 0.8, :footer => 0.9)
+ @pm.set(left: 1.1, right: 1.2, top: 1.3, bottom: 1.4, header: 0.8, footer: 0.9)
assert_in_delta(1.1, @pm.left)
assert_in_delta(1.2, @pm.right)
@@ -41,7 +41,7 @@ class TestPageMargins < Test::Unit::TestCase
end
def test_set_some_values
- @pm.set(:left => 1.1, :right => 1.2)
+ @pm.set(left: 1.1, right: 1.2)
assert_in_delta(1.1, @pm.left)
assert_in_delta(1.2, @pm.right)
diff --git a/test/workbook/worksheet/tc_page_set_up_pr.rb b/test/workbook/worksheet/tc_page_set_up_pr.rb
index 36a2a6f4..8a9ee695 100644
--- a/test/workbook/worksheet/tc_page_set_up_pr.rb
+++ b/test/workbook/worksheet/tc_page_set_up_pr.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestPageSetUpPr < Test::Unit::TestCase
def setup
- @page_setup_pr = Axlsx::PageSetUpPr.new(:fit_to_page => true, :auto_page_breaks => true)
+ @page_setup_pr = Axlsx::PageSetUpPr.new(fit_to_page: true, auto_page_breaks: true)
end
def test_fit_to_page
diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb
index 95703c1c..db52e4fb 100644
--- a/test/workbook/worksheet/tc_page_setup.rb
+++ b/test/workbook/worksheet/tc_page_setup.rb
@@ -5,7 +5,7 @@ require 'tc_helper'
class TestPageSetup < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
- ws = @p.workbook.add_worksheet :name => "hmmm"
+ ws = @p.workbook.add_worksheet name: "hmmm"
@ps = ws.page_setup
end
@@ -19,14 +19,14 @@ class TestPageSetup < Test::Unit::TestCase
end
def test_initialize_with_options
- page_setup = { :fit_to_height => 1,
- :fit_to_width => 2,
- :orientation => :landscape,
- :paper_height => "297mm",
- :paper_width => "210mm",
- :scale => 50 }
+ page_setup = { fit_to_height: 1,
+ fit_to_width: 2,
+ orientation: :landscape,
+ paper_height: "297mm",
+ paper_width: "210mm",
+ scale: 50 }
- optioned = @p.workbook.add_worksheet(:name => 'optioned', :page_setup => page_setup).page_setup
+ optioned = @p.workbook.add_worksheet(name: 'optioned', page_setup: page_setup).page_setup
assert_equal(1, optioned.fit_to_height)
assert_equal(2, optioned.fit_to_width)
@@ -37,7 +37,7 @@ class TestPageSetup < Test::Unit::TestCase
end
def test_set_all_values
- @ps.set(:fit_to_height => 1, :fit_to_width => 2, :orientation => :landscape, :paper_height => "297mm", :paper_width => "210mm", :scale => 50)
+ @ps.set(fit_to_height: 1, fit_to_width: 2, orientation: :landscape, paper_height: "297mm", paper_width: "210mm", scale: 50)
assert_equal(1, @ps.fit_to_height)
assert_equal(2, @ps.fit_to_width)
@@ -53,7 +53,7 @@ class TestPageSetup < Test::Unit::TestCase
end
def test_set_some_values
- @ps.set(:fit_to_width => 2, :orientation => :portrait)
+ @ps.set(fit_to_width: 2, orientation: :portrait)
assert_equal(2, @ps.fit_to_width)
assert_equal(:portrait, @ps.orientation)
@@ -70,27 +70,27 @@ class TestPageSetup < Test::Unit::TestCase
def test_with_height_fit_to_page?
assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?)
- @ps.set(:fit_to_height => 1)
+ @ps.set(fit_to_height: 1)
assert_predicate(@ps, :fit_to_page?)
end
def test_with_width_fit_to_page?
assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?)
- @ps.set(:fit_to_width => 1)
+ @ps.set(fit_to_width: 1)
assert_predicate(@ps, :fit_to_page?)
end
def test_to_xml_all_values
- @ps.set(:fit_to_height => 1, :fit_to_width => 2, :orientation => :landscape, :paper_height => "297mm", :paper_width => "210mm", :scale => 50)
+ @ps.set(fit_to_height: 1, fit_to_width: 2, orientation: :landscape, paper_height: "297mm", paper_width: "210mm", scale: 50)
doc = Nokogiri::XML.parse(@ps.to_xml_string)
assert_equal(1, doc.xpath(".//pageSetup[@fitToHeight='1'][@fitToWidth='2'][@orientation='landscape'][@paperHeight='297mm'][@paperWidth='210mm'][@scale='50']").size)
end
def test_to_xml_some_values
- @ps.set(:orientation => :portrait)
+ @ps.set(orientation: :portrait)
doc = Nokogiri::XML.parse(@ps.to_xml_string)
assert_equal(1, doc.xpath(".//pageSetup[@orientation='portrait']").size)
@@ -138,15 +138,15 @@ class TestPageSetup < Test::Unit::TestCase
end
def test_fit_to
- fits = @ps.fit_to(:width => 1)
+ fits = @ps.fit_to(width: 1)
assert_equal([1, 999], fits)
- fits = @ps.fit_to :height => 1
+ fits = @ps.fit_to height: 1
assert_equal([999, 1], fits)
- fits = @ps.fit_to :height => 7, :width => 2
+ fits = @ps.fit_to height: 7, width: 2
assert_equal([2, 7], fits)
- assert_raise(ArgumentError) { puts @ps.fit_to(:width => true) }
+ assert_raise(ArgumentError) { puts @ps.fit_to(width: true) }
end
end
diff --git a/test/workbook/worksheet/tc_pane.rb b/test/workbook/worksheet/tc_pane.rb
index 59d411a0..cf94fac7 100644
--- a/test/workbook/worksheet/tc_pane.rb
+++ b/test/workbook/worksheet/tc_pane.rb
@@ -5,8 +5,8 @@ require 'tc_helper'
class TestPane < Test::Unit::TestCase
def setup
# inverse defaults for booleans
- @nil_options = { :active_pane => :bottom_left, :state => :frozen, :top_left_cell => 'A2' }
- @int_0_options = { :x_split => 2, :y_split => 2 }
+ @nil_options = { active_pane: :bottom_left, state: :frozen, top_left_cell: 'A2' }
+ @int_0_options = { x_split: 2, y_split: 2 }
@options = @nil_options.merge(@int_0_options)
@pane = Axlsx::Pane.new(@options)
end
@@ -48,7 +48,7 @@ class TestPane < Test::Unit::TestCase
end
def test_to_xml_frozen
- pane = Axlsx::Pane.new :state => :frozen, :y_split => 2
+ pane = Axlsx::Pane.new state: :frozen, y_split: 2
doc = Nokogiri::XML(pane.to_xml_string)
assert_equal(1, doc.xpath("//pane[@topLeftCell='A3']").size)
diff --git a/test/workbook/worksheet/tc_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb
index f5b23a96..606982db 100644
--- a/test/workbook/worksheet/tc_pivot_table.rb
+++ b/test/workbook/worksheet/tc_pivot_table.rb
@@ -60,22 +60,22 @@ class TestPivotTable < Test::Unit::TestCase
assert_equal(['Year', 'Month'], pivot_table.rows)
assert_equal(['Type'], pivot_table.columns)
- assert_equal([{ :ref => "Sales" }], pivot_table.data)
+ assert_equal([{ ref: "Sales" }], pivot_table.data)
assert_equal(['Region'], pivot_table.pages)
shared_test_pivot_table_xml_validity(pivot_table)
end
def test_add_pivot_table_with_options_on_data_field
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5') do |pt|
- pt.data = [{ :ref => "Sales", :subtotal => 'average' }]
+ pt.data = [{ ref: "Sales", subtotal: 'average' }]
end
- assert_equal([{ :ref => "Sales", :subtotal => 'average' }], pivot_table.data)
+ assert_equal([{ ref: "Sales", subtotal: 'average' }], pivot_table.data)
end
def test_add_pivot_table_with_style_info
- style_info_data = { :name => "PivotStyleMedium9", :showRowHeaders => "1", :showLastColumn => "0" }
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { :style_info => style_info_data }) do |pt|
+ style_info_data = { name: "PivotStyleMedium9", showRowHeaders: "1", showLastColumn: "0" }
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { style_info: style_info_data }) do |pt|
pt.rows = ['Year', 'Month']
pt.columns = ['Type']
pt.data = ['Sales']
@@ -87,7 +87,7 @@ class TestPivotTable < Test::Unit::TestCase
end
def test_add_pivot_table_with_row_without_subtotals
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5', { :no_subtotals_on_headers => ['Year'] }) do |pt|
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5', { no_subtotals_on_headers: ['Year'] }) do |pt|
pt.data = ['Sales']
pt.rows = ['Year', 'Month']
end
@@ -96,7 +96,7 @@ class TestPivotTable < Test::Unit::TestCase
end
def test_add_pivot_table_with_months_sorted
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { :sort_on_headers => ['Month'] }) do |pt|
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { sort_on_headers: ['Month'] }) do |pt|
pt.data = ['Sales']
pt.rows = ['Year', 'Month']
end
@@ -145,7 +145,7 @@ class TestPivotTable < Test::Unit::TestCase
end
def test_to_xml_string
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { :no_subtotals_on_headers => ['Year'] }) do |pt|
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { no_subtotals_on_headers: ['Year'] }) do |pt|
pt.rows = ['Year', 'Month']
pt.columns = ['Type']
pt.data = ['Sales']
@@ -156,14 +156,14 @@ class TestPivotTable < Test::Unit::TestCase
def test_to_xml_string_with_options_on_data_field
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
- pt.data = [{ :ref => "Sales", :subtotal => 'average' }]
+ pt.data = [{ ref: "Sales", subtotal: 'average' }]
end
shared_test_pivot_table_xml_validity(pivot_table)
end
def test_add_pivot_table_with_format_options_on_data_field
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
- pt.data = [{ :ref => "Sales", :subtotal => 'sum', num_fmt: 4 }]
+ pt.data = [{ ref: "Sales", subtotal: 'sum', num_fmt: 4 }]
end
doc = Nokogiri::XML(pivot_table.to_xml_string)
diff --git a/test/workbook/worksheet/tc_print_options.rb b/test/workbook/worksheet/tc_print_options.rb
index 10639bcf..2d2dfaf8 100644
--- a/test/workbook/worksheet/tc_print_options.rb
+++ b/test/workbook/worksheet/tc_print_options.rb
@@ -5,7 +5,7 @@ require 'tc_helper'
class TestPrintOptions < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- ws = p.workbook.add_worksheet :name => "hmmm"
+ ws = p.workbook.add_worksheet name: "hmmm"
@po = ws.print_options
end
@@ -17,7 +17,7 @@ class TestPrintOptions < Test::Unit::TestCase
end
def test_initialize_with_options
- optioned = Axlsx::PrintOptions.new(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
+ optioned = Axlsx::PrintOptions.new(grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true)
assert(optioned.grid_lines)
assert(optioned.headings)
@@ -26,7 +26,7 @@ class TestPrintOptions < Test::Unit::TestCase
end
def test_set_all_values
- @po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
+ @po.set(grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true)
assert(@po.grid_lines)
assert(@po.headings)
@@ -35,7 +35,7 @@ class TestPrintOptions < Test::Unit::TestCase
end
def test_set_some_values
- @po.set(:grid_lines => true, :headings => true)
+ @po.set(grid_lines: true, headings: true)
assert(@po.grid_lines)
assert(@po.headings)
@@ -44,7 +44,7 @@ class TestPrintOptions < Test::Unit::TestCase
end
def test_to_xml
- @po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true)
+ @po.set(grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true)
doc = Nokogiri::XML.parse(@po.to_xml_string)
assert_equal(1, doc.xpath(".//printOptions[@gridLines=1][@headings=1][@horizontalCentered=1][@verticalCentered=1]").size)
diff --git a/test/workbook/worksheet/tc_protected_range.rb b/test/workbook/worksheet/tc_protected_range.rb
index 44fe8333..db28126a 100644
--- a/test/workbook/worksheet/tc_protected_range.rb
+++ b/test/workbook/worksheet/tc_protected_range.rb
@@ -9,7 +9,7 @@ class TestProtectedRange < Test::Unit::TestCase
end
def test_initialize_options
- assert_nothing_raised { Axlsx::ProtectedRange.new(:sqref => 'A1:B1', :name => "only bob") }
+ assert_nothing_raised { Axlsx::ProtectedRange.new(sqref: 'A1:B1', name: "only bob") }
end
def test_range
diff --git a/test/workbook/worksheet/tc_rich_text.rb b/test/workbook/worksheet/tc_rich_text.rb
index ed3ec9ca..e28ea0af 100644
--- a/test/workbook/worksheet/tc_rich_text.rb
+++ b/test/workbook/worksheet/tc_rich_text.rb
@@ -5,12 +5,12 @@ require 'tc_helper'
class RichText < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "hmmmz"
- p.workbook.styles.add_style :sz => 20
+ @ws = p.workbook.add_worksheet name: "hmmmz"
+ p.workbook.styles.add_style sz: 20
@rt = Axlsx::RichText.new
b = true
27.times do |r|
- @rt.add_run "run #{r}, ", :b => (b = !b), :i => !b
+ @rt.add_run "run #{r}, ", b: (b = !b), i: !b
end
@row = @ws.add_row [@rt]
@c = @row.first
@@ -18,9 +18,9 @@ class RichText < Test::Unit::TestCase
def test_initialize
assert_equal(@c.value, @rt)
- rt_direct = Axlsx::RichText.new('hi', :i => true)
+ rt_direct = Axlsx::RichText.new('hi', i: true)
rt_indirect = Axlsx::RichText.new
- rt_indirect.add_run('hi', :i => true)
+ rt_indirect.add_run('hi', i: true)
assert_equal(1, rt_direct.runs.length)
assert_equal(1, rt_indirect.runs.length)
@@ -40,7 +40,7 @@ class RichText < Test::Unit::TestCase
end
def test_implicit_richtext
- rt = Axlsx::RichText.new('a', :b => true)
+ rt = Axlsx::RichText.new('a', b: true)
row_rt = @ws.add_row [rt]
row_imp = @ws.add_row ['a']
row_imp[0].b = true
diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb
index e9011832..6274dda8 100644
--- a/test/workbook/worksheet/tc_rich_text_run.rb
+++ b/test/workbook/worksheet/tc_rich_text_run.rb
@@ -5,8 +5,8 @@ require 'tc_helper'
class RichTextRun < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
- @ws = @p.workbook.add_worksheet :name => "hmmmz"
- @p.workbook.styles.add_style :sz => 20
+ @ws = @p.workbook.add_worksheet name: "hmmmz"
+ @p.workbook.styles.add_style sz: 20
@rtr = Axlsx::RichTextRun.new('hihihi', b: true, i: false)
@rtr2 = Axlsx::RichTextRun.new('hihi2hi2', b: false, i: true)
@rt = Axlsx::RichText.new
@@ -23,7 +23,7 @@ class RichTextRun < Test::Unit::TestCase
end
def test_font_size_with_custom_style_and_no_sz
- @c.style = @c.row.worksheet.workbook.styles.add_style :bg_color => 'FF00FF'
+ @c.style = @c.row.worksheet.workbook.styles.add_style bg_color: 'FF00FF'
sz = @rtr.send(:font_size)
assert_equal(sz, @c.row.worksheet.workbook.styles.fonts.first.sz * 1.5)
@@ -33,14 +33,14 @@ class RichTextRun < Test::Unit::TestCase
end
def test_font_size_with_bolding
- @c.style = @c.row.worksheet.workbook.styles.add_style :b => true
+ @c.style = @c.row.worksheet.workbook.styles.add_style b: true
assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @rtr.send(:font_size))
assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @rtr2.send(:font_size)) # is this the correct behaviour?
end
def test_font_size_with_custom_sz
- @c.style = @c.row.worksheet.workbook.styles.add_style :sz => 52
+ @c.style = @c.row.worksheet.workbook.styles.add_style sz: 52
sz = @rtr.send(:font_size)
assert_equal(52 * 1.5, sz)
@@ -150,11 +150,11 @@ class RichTextRun < Test::Unit::TestCase
end
def test_multiline_autowidth
- wrap = @p.workbook.styles.add_style({ :alignment => { :wrap_text => true } })
- awtr = Axlsx::RichTextRun.new('I\'m bold' + "\n", :b => true)
+ wrap = @p.workbook.styles.add_style({ alignment: { wrap_text: true } })
+ awtr = Axlsx::RichTextRun.new('I\'m bold' + "\n", b: true)
rt = Axlsx::RichText.new
rt.runs << awtr
- @ws.add_row [rt], :style => wrap
+ @ws.add_row [rt], style: wrap
ar = [0]
awtr.autowidth(ar)
diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb
index 273487ac..52ed036c 100644
--- a/test/workbook/worksheet/tc_row.rb
+++ b/test/workbook/worksheet/tc_row.rb
@@ -5,7 +5,7 @@ require 'tc_helper'
class TestRow < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "hmmm"
+ @ws = p.workbook.add_worksheet name: "hmmm"
@row = @ws.add_row
end
@@ -17,7 +17,7 @@ class TestRow < Test::Unit::TestCase
end
def test_initialize_with_fixed_height
- row = @ws.add_row([1, 2, 3, 4, 5], :height => 40)
+ row = @ws.add_row([1, 2, 3, 4, 5], height: 40)
assert_equal(40, row.height)
assert(row.custom_height)
@@ -55,13 +55,13 @@ class TestRow < Test::Unit::TestCase
end
def test_array_to_cells
- r = @ws.add_row [1, 2, 3], :style => 1, :types => [:integer, :string, :float]
+ r = @ws.add_row [1, 2, 3], style: 1, types: [:integer, :string, :float]
assert_equal(3, r.cells.size)
r.cells.each do |c|
assert_equal(1, c.style)
end
- r = @ws.add_row [1, 2, 3], :style => [1]
+ r = @ws.add_row [1, 2, 3], style: [1]
assert_equal(1, r.cells.first.style, "only apply style to cells with at the same index of of the style array")
assert_equal(0, r.cells.last.style, "only apply style to cells with at the same index of of the style array")
diff --git a/test/workbook/worksheet/tc_selection.rb b/test/workbook/worksheet/tc_selection.rb
index d68500a5..d4f34e3d 100644
--- a/test/workbook/worksheet/tc_selection.rb
+++ b/test/workbook/worksheet/tc_selection.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestSelection < Test::Unit::TestCase
def setup
- @options = { :active_cell => 'A2', :active_cell_id => 1, :pane => :top_left, :sqref => 'A2' }
+ @options = { active_cell: 'A2', active_cell_id: 1, pane: :top_left, sqref: 'A2' }
@selection = Axlsx::Selection.new(@options)
end
@@ -34,12 +34,12 @@ class TestSelection < Test::Unit::TestCase
def test_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "sheetview"
+ @ws = p.workbook.add_worksheet name: "sheetview"
@ws.sheet_view do |vs|
- vs.add_selection(:top_left, { :active_cell => 'B2', :sqref => 'B2' })
- vs.add_selection(:top_right, { :active_cell => 'I10', :sqref => 'I10' })
- vs.add_selection(:bottom_left, { :active_cell => 'E55', :sqref => 'E55' })
- vs.add_selection(:bottom_right, { :active_cell => 'I57', :sqref => 'I57' })
+ vs.add_selection(:top_left, { active_cell: 'B2', sqref: 'B2' })
+ vs.add_selection(:top_right, { active_cell: 'I10', sqref: 'I10' })
+ vs.add_selection(:bottom_left, { active_cell: 'E55', sqref: 'E55' })
+ vs.add_selection(:bottom_right, { active_cell: 'I57', sqref: 'I57' })
end
doc = Nokogiri::XML.parse(@ws.to_xml_string)
diff --git a/test/workbook/worksheet/tc_sheet_calc_pr.rb b/test/workbook/worksheet/tc_sheet_calc_pr.rb
index cd1f6506..9598b0c0 100644
--- a/test/workbook/worksheet/tc_sheet_calc_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_calc_pr.rb
@@ -4,7 +4,7 @@ require 'tc_helper'
class TestSheetCalcPr < Test::Unit::TestCase
def setup
- @sheet_calc_pr = Axlsx::SheetCalcPr.new(:full_calc_on_load => false)
+ @sheet_calc_pr = Axlsx::SheetCalcPr.new(full_calc_on_load: false)
end
def test_full_calc_on_load
diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb
index 18d62249..ac7048cd 100644
--- a/test/workbook/worksheet/tc_sheet_format_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_format_pr.rb
@@ -5,15 +5,15 @@ require 'tc_helper'
class TestSheetFormatPr < Test::Unit::TestCase
def setup
@options = {
- :base_col_width => 5,
- :default_col_width => 7.2,
- :default_row_height => 5.2,
- :custom_height => true,
- :zero_height => false,
- :thick_top => true,
- :thick_bottom => true,
- :outline_level_row => 0,
- :outline_level_col => 0
+ base_col_width: 5,
+ default_col_width: 7.2,
+ default_row_height: 5.2,
+ custom_height: true,
+ zero_height: false,
+ thick_top: true,
+ thick_bottom: true,
+ outline_level_row: 0,
+ outline_level_col: 0
}
@sheet_format_pr = Axlsx::SheetFormatPr.new(@options)
end
diff --git a/test/workbook/worksheet/tc_sheet_pr.rb b/test/workbook/worksheet/tc_sheet_pr.rb
index be87ebf7..58c61bb5 100644
--- a/test/workbook/worksheet/tc_sheet_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_pr.rb
@@ -6,16 +6,16 @@ class TestSheetPr < Test::Unit::TestCase
def setup
worksheet = Axlsx::Package.new.workbook.add_worksheet
@options = {
- :sync_horizontal => false,
- :sync_vertical => false,
- :transition_evaluation => true,
- :transition_entry => true,
- :published => false,
- :filter_mode => true,
- :enable_format_conditions_calculation => false,
- :code_name => '007',
- :sync_ref => 'foo',
- :tab_color => 'FFFF6666'
+ sync_horizontal: false,
+ sync_vertical: false,
+ transition_evaluation: true,
+ transition_entry: true,
+ published: false,
+ filter_mode: true,
+ enable_format_conditions_calculation: false,
+ code_name: '007',
+ sync_ref: 'foo',
+ tab_color: 'FFFF6666'
}
@sheet_pr = Axlsx::SheetPr.new(worksheet, @options)
end
diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb
index 4a5e22e8..ebfff4b6 100644
--- a/test/workbook/worksheet/tc_sheet_protection.rb
+++ b/test/workbook/worksheet/tc_sheet_protection.rb
@@ -25,12 +25,12 @@ require 'tc_helper'
class TestSheetProtection < Test::Unit::TestCase
def setup
# inverse defaults
- @boolean_options = { :sheet => false, :objects => true, :scenarios => true, :format_cells => false,
- :format_columns => false, :format_rows => false, :insert_columns => false, :insert_rows => false,
- :insert_hyperlinks => false, :delete_columns => false, :delete_rows => false, :select_locked_cells => true,
- :sort => false, :auto_filter => false, :pivot_tables => false, :select_unlocked_cells => true }
+ @boolean_options = { sheet: false, objects: true, scenarios: true, format_cells: false,
+ format_columns: false, format_rows: false, insert_columns: false, insert_rows: false,
+ insert_hyperlinks: false, delete_columns: false, delete_rows: false, select_locked_cells: true,
+ sort: false, auto_filter: false, pivot_tables: false, select_unlocked_cells: true }
- @string_options = { :password => nil }
+ @string_options = { password: nil }
@options = @boolean_options.merge(@string_options)
diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb
index b52b6954..498c2056 100644
--- a/test/workbook/worksheet/tc_sheet_view.rb
+++ b/test/workbook/worksheet/tc_sheet_view.rb
@@ -5,16 +5,16 @@ require 'tc_helper'
class TestSheetView < Test::Unit::TestCase
def setup
# inverse defaults for booleans
- @boolean_options = { :right_to_left => true, :show_formulas => true, :show_outline_symbols => true,
- :show_white_space => true, :tab_selected => true, :default_grid_color => false, :show_grid_lines => false,
- :show_row_col_headers => false, :show_ruler => false, :show_zeros => false, :window_protection => true }
- @symbol_options = { :view => :page_break_preview }
- @nil_options = { :color_id => 2, :top_left_cell => 'A2' }
- @int_0 = { :zoom_scale_normal => 100, :zoom_scale_page_layout_view => 100, :zoom_scale_sheet_layout_view => 100, :workbook_view_id => 2 }
- @int_100 = { :zoom_scale => 10 }
+ @boolean_options = { right_to_left: true, show_formulas: true, show_outline_symbols: true,
+ show_white_space: true, tab_selected: true, default_grid_color: false, show_grid_lines: false,
+ show_row_col_headers: false, show_ruler: false, show_zeros: false, window_protection: true }
+ @symbol_options = { view: :page_break_preview }
+ @nil_options = { color_id: 2, top_left_cell: 'A2' }
+ @int_0 = { zoom_scale_normal: 100, zoom_scale_page_layout_view: 100, zoom_scale_sheet_layout_view: 100, workbook_view_id: 2 }
+ @int_100 = { zoom_scale: 10 }
- @integer_options = { :color_id => 2, :workbook_view_id => 2 }.merge(@int_0).merge(@int_100)
- @string_options = { :top_left_cell => 'A2' }
+ @integer_options = { color_id: 2, workbook_view_id: 2 }.merge(@int_0).merge(@int_100)
+ @string_options = { top_left_cell: 'A2' }
@options = @boolean_options.merge(@boolean_options).merge(@symbol_options).merge(@nil_options).merge(@int_0).merge(@int_100)
@@ -189,7 +189,7 @@ class TestSheetView < Test::Unit::TestCase
def test_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name => "sheetview"
+ @ws = p.workbook.add_worksheet name: "sheetview"
@ws.sheet_view do |vs|
vs.view = :page_break_preview
end
@@ -206,7 +206,7 @@ class TestSheetView < Test::Unit::TestCase
end
def test_add_selection
- @sv.add_selection(:top_left, :active_cell => "A1")
+ @sv.add_selection(:top_left, active_cell: "A1")
assert_equal('A1', @sv.selections[:top_left].active_cell)
end
diff --git a/test/workbook/worksheet/tc_table.rb b/test/workbook/worksheet/tc_table.rb
index 38f909b9..3769ac02 100644
--- a/test/workbook/worksheet/tc_table.rb
+++ b/test/workbook/worksheet/tc_table.rb
@@ -17,7 +17,7 @@ class TestTable < Test::Unit::TestCase
end
def test_table_style_info
- table = @ws.add_table('A1:D5', :name => 'foo', :style_info => { :show_row_stripes => true, :name => "TableStyleMedium25" })
+ table = @ws.add_table('A1:D5', name: 'foo', style_info: { show_row_stripes: true, name: "TableStyleMedium25" })
assert_equal('TableStyleMedium25', table.table_style_info.name)
assert(table.table_style_info.show_row_stripes)
@@ -25,7 +25,7 @@ class TestTable < Test::Unit::TestCase
def test_add_table
name = "test"
- table = @ws.add_table("A1:D5", :name => name)
+ table = @ws.add_table("A1:D5", name: name)
assert(table.is_a?(Axlsx::Table), "must create a table")
assert_equal(@ws.workbook.tables.last, table, "must be added to workbook table collection")
diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb
index 60a4c113..6cb12b94 100644
--- a/test/workbook/worksheet/tc_table_style_info.rb
+++ b/test/workbook/worksheet/tc_table_style_info.rb
@@ -9,12 +9,12 @@ class TestTableStyleInfo < Test::Unit::TestCase
40.times do
@ws.add_row %w(aa bb cc dd ee ff gg hh ii jj kk)
end
- @table = @ws.add_table(Axlsx::cell_range([@ws.rows.first.cells.first, @ws.rows.last.cells.last], false), :name => 'foo')
- @options = { :show_first_column => 1,
- :show_last_column => 1,
- :show_row_stripes => 1,
- :show_column_stripes => 1,
- :name => "TableStyleDark4" }
+ @table = @ws.add_table(Axlsx::cell_range([@ws.rows.first.cells.first, @ws.rows.last.cells.last], false), name: 'foo')
+ @options = { show_first_column: 1,
+ show_last_column: 1,
+ show_row_stripes: 1,
+ show_column_stripes: 1,
+ name: "TableStyleDark4" }
end
def test_initialize
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index 3c54e3fc..4ec74efb 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -33,12 +33,12 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_name_unique
- assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name => n) }
+ assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(name: n) }
end
def test_name_unique_only_checks_other_worksheet_names
assert_nothing_raised { @ws.name = @ws.name }
- assert_nothing_raised { Axlsx::Package.new.workbook.add_worksheet :name => 'Sheet1' }
+ assert_nothing_raised { Axlsx::Package.new.workbook.add_worksheet name: 'Sheet1' }
end
def test_exception_if_name_too_long
@@ -117,11 +117,11 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_initialization_options
- page_margins = { :left => 2, :right => 2, :bottom => 2, :top => 2, :header => 2, :footer => 2 }
- page_setup = { :fit_to_height => 1, :fit_to_width => 1, :orientation => :landscape, :paper_width => "210mm", :paper_height => "297mm", :scale => 80 }
- print_options = { :grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true }
- header_footer = { :different_first => false, :different_odd_even => false, :odd_header => 'Header' }
- optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer)
+ page_margins = { left: 2, right: 2, bottom: 2, top: 2, header: 2, footer: 2 }
+ page_setup = { fit_to_height: 1, fit_to_width: 1, orientation: :landscape, paper_width: "210mm", paper_height: "297mm", scale: 80 }
+ print_options = { grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true }
+ header_footer = { different_first: false, different_odd_even: false, odd_header: 'Header' }
+ optioned = @ws.workbook.add_worksheet(name: 'bob', page_margins: page_margins, page_setup: page_setup, print_options: print_options, header_footer: header_footer)
page_margins.each_key do |key|
assert_equal(page_margins[key], optioned.page_margins.send(key))
@@ -247,7 +247,7 @@ class TestWorksheet < Test::Unit::TestCase
@ws.add_row [1, 2, 3, 4]
@ws.add_row [1, 2, 3, 4]
@ws.add_row [1, 2, 3, 4]
- @ws.col_style((1..2), 1, :row_offset => 1)
+ @ws.col_style((1..2), 1, row_offset: 1)
@ws.rows[(1..-1)].each do |r|
assert_equal(1, r.cells[1].style)
assert_equal(1, r.cells[2].style)
@@ -287,14 +287,14 @@ class TestWorksheet < Test::Unit::TestCase
@ws.add_row [1, 2, 3, 4]
@ws.add_row [1, 2, 3, 4]
@ws.add_row [1, 2, 3, 4]
- @ws.row_style 1, 1, :col_offset => 1
+ @ws.row_style 1, 1, col_offset: 1
@ws.rows[1].cells[(1..-1)].each do |c|
assert_equal(1, c.style)
end
assert_equal(0, @ws.rows[1].cells[0].style)
assert_equal(0, @ws.rows[2].cells[1].style)
- @ws.row_style(1..2, 1, :col_offset => 2)
+ @ws.row_style(1..2, 1, col_offset: 2)
@ws.rows[(1..2)].each do |r|
r.cells[(2..-1)].each do |c|
assert_equal(1, c.style)
@@ -477,9 +477,9 @@ class TestWorksheet < Test::Unit::TestCase
# Make sure the XML for all optional elements (like pageMargins, autoFilter, ...)
# is generated in correct order.
def test_valid_with_optional_elements
- @ws.page_margins.set :left => 9
- @ws.page_setup.set :fit_to_width => 1
- @ws.print_options.set :headings => true
+ @ws.page_margins.set left: 9
+ @ws.page_setup.set fit_to_width: 1
+ @ws.print_options.set headings: true
@ws.auto_filter.range = "A1:C3"
@ws.merge_cells "A4:A5"
@ws.add_chart Axlsx::Pie3DChart
@@ -501,10 +501,10 @@ class TestWorksheet < Test::Unit::TestCase
@ws.add_chart Axlsx::Pie3DChart
assert_equal(1, @ws.relationships.size, "multiple charts still only result in one relationship")
- @ws.add_comment :text => 'builder', :author => 'bob', :ref => @ws.rows.last.cells.last
+ @ws.add_comment text: 'builder', author: 'bob', ref: @ws.rows.last.cells.last
assert_equal(3, @ws.relationships.size, "adding a comment adds 2 relationships")
- @ws.add_comment :text => 'not that is a comment!', :author => 'travis', :ref => "A1"
+ @ws.add_comment text: 'not that is a comment!', author: 'travis', ref: "A1"
assert_equal(3, @ws.relationships.size, "adding multiple comments in the same worksheet should not add any additional comment relationships")
@ws.add_pivot_table 'G5:G6', 'A1:D10'
@@ -513,7 +513,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_set_fixed_width_column
- @ws.add_row ["mule", "donkey", "horse"], :widths => [20, :ignore, nil]
+ @ws.add_row ["mule", "donkey", "horse"], widths: [20, :ignore, nil]
assert_equal(3, @ws.column_info.size, "a data item for each column")
assert_equal(20, @ws.column_info[0].width, "adding a row with fixed width updates :fixed attribute")
@@ -521,7 +521,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_fixed_height
- @ws.add_row [1, 2, 3], :height => 40
+ @ws.add_row [1, 2, 3], height: 40
assert_equal(40, @ws.rows[-1].height)
end
@@ -641,7 +641,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_sheet_pr_for_auto_filter
@ws.auto_filter.range = 'A1:D9'
- @ws.auto_filter.add_column 0, :filters, :filter_items => [1]
+ @ws.auto_filter.add_column 0, :filters, filter_items: [1]
doc = Nokogiri::XML(@ws.to_xml_string)
assert(doc.xpath('//sheetPr[@filterMode=1]'))
@@ -667,7 +667,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_worksheet_does_not_get_added_to_workbook_on_initialize_failure
assert_equal(1, @wb.worksheets.size)
- assert_raise(ArgumentError) { @wb.add_worksheet(:name => 'Sheet1') }
+ assert_raise(ArgumentError) { @wb.add_worksheet(name: 'Sheet1') }
assert_equal(1, @wb.worksheets.size)
end
diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb
index 19bacc0e..e4e82e88 100644
--- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb
+++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb
@@ -7,7 +7,7 @@ class TestWorksheetHyperlink < Test::Unit::TestCase
p = Axlsx::Package.new
wb = p.workbook
@ws = wb.add_worksheet
- @options = { :location => 'https://github.com/randym/axlsx?foo=1&bar=2', :tooltip => 'axlsx', :ref => 'A1', :display => 'AXSLX', :target => :internal }
+ @options = { location: 'https://github.com/randym/axlsx?foo=1&bar=2', tooltip: 'axlsx', ref: 'A1', display: 'AXSLX', target: :internal }
@a = @ws.add_hyperlink @options
end