summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/worksheet
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-04-08 11:53:12 +0200
committerGeremia Taglialatela <[email protected]>2023-04-08 11:53:12 +0200
commit55526805cf28cc91a22df5811b26cd23bdefa8d3 (patch)
tree2cbc6403b385078b0ed5e275c49f0c60522bdd16 /test/workbook/worksheet
parentacf00d356494ef504c3de0e4a0db6b25f2bd7636 (diff)
downloadcaxlsx-55526805cf28cc91a22df5811b26cd23bdefa8d3.tar.gz
caxlsx-55526805cf28cc91a22df5811b26cd23bdefa8d3.zip
Fix space-related offenses
- Layout/SpaceAfterComma - Layout/SpaceAroundEqualsInParameterDefault - Layout/SpaceAroundOperators - Layout/SpaceBeforeBlockBraces - Layout/SpaceInsideBlockBraces - Layout/SpaceInsideHashLiteralBraces - Layout/SpaceInsideParens
Diffstat (limited to 'test/workbook/worksheet')
-rw-r--r--test/workbook/worksheet/auto_filter/tc_auto_filter.rb2
-rw-r--r--test/workbook/worksheet/auto_filter/tc_filters.rb2
-rw-r--r--test/workbook/worksheet/tc_border_creator.rb6
-rw-r--r--test/workbook/worksheet/tc_break.rb2
-rw-r--r--test/workbook/worksheet/tc_cell.rb28
-rw-r--r--test/workbook/worksheet/tc_col.rb4
-rw-r--r--test/workbook/worksheet/tc_color_scale.rb14
-rw-r--r--test/workbook/worksheet/tc_comment.rb2
-rw-r--r--test/workbook/worksheet/tc_comments.rb4
-rw-r--r--test/workbook/worksheet/tc_conditional_formatting.rb24
-rw-r--r--test/workbook/worksheet/tc_data_bar.rb8
-rw-r--r--test/workbook/worksheet/tc_data_validation.rb20
-rw-r--r--test/workbook/worksheet/tc_date_time_converter.rb4
-rw-r--r--test/workbook/worksheet/tc_icon_set.rb8
-rw-r--r--test/workbook/worksheet/tc_page_margins.rb2
-rw-r--r--test/workbook/worksheet/tc_page_setup.rb4
-rw-r--r--test/workbook/worksheet/tc_pivot_table.rb54
-rw-r--r--test/workbook/worksheet/tc_pivot_table_cache_definition.rb2
-rw-r--r--test/workbook/worksheet/tc_protected_range.rb4
-rw-r--r--test/workbook/worksheet/tc_rich_text.rb6
-rw-r--r--test/workbook/worksheet/tc_rich_text_run.rb4
-rw-r--r--test/workbook/worksheet/tc_row.rb24
-rw-r--r--test/workbook/worksheet/tc_sheet_format_pr.rb12
-rw-r--r--test/workbook/worksheet/tc_sheet_pr.rb2
-rw-r--r--test/workbook/worksheet/tc_sheet_protection.rb2
-rw-r--r--test/workbook/worksheet/tc_table.rb2
-rw-r--r--test/workbook/worksheet/tc_table_style_info.rb2
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb100
28 files changed, 174 insertions, 174 deletions
diff --git a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
index 60089d22..eb561554 100644
--- a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
+++ b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
class TestAutoFilter < Test::Unit::TestCase
def setup
ws = Axlsx::Package.new.workbook.add_worksheet
- 3.times { |index| ws.add_row [1*index,2*index,3*index] }
+ 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]
diff --git a/test/workbook/worksheet/auto_filter/tc_filters.rb b/test/workbook/worksheet/auto_filter/tc_filters.rb
index d1c30446..8e853772 100644
--- a/test/workbook/worksheet/auto_filter/tc_filters.rb
+++ b/test/workbook/worksheet/auto_filter/tc_filters.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
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 }],
+ :date_group_items => [{ :date_time_grouping => :year, :year => 2011, :month => 11, :day => 11, :hour => 0, :minute => 0, :second => 0 }],
:blank => true)
end
diff --git a/test/workbook/worksheet/tc_border_creator.rb b/test/workbook/worksheet/tc_border_creator.rb
index eb27fe98..c9f3df8f 100644
--- a/test/workbook/worksheet/tc_border_creator.rb
+++ b/test/workbook/worksheet/tc_border_creator.rb
@@ -8,7 +8,7 @@ class TestBorderCreator < Test::Unit::TestCase
end
def test_initialize
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
bc = Axlsx::BorderCreator.new(worksheet: @ws, cells: @ws["A1:B1"])
assert_equal bc.instance_variable_get(:@edges), Axlsx::Border::EDGES
@@ -22,7 +22,7 @@ class TestBorderCreator < Test::Unit::TestCase
end
def test_initialize_edges
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
bc = Axlsx::BorderCreator.new(worksheet: @ws, cells: @ws["A1:B1"], edges: nil)
assert_equal bc.instance_variable_get(:@edges), Axlsx::Border::EDGES
@@ -48,7 +48,7 @@ class TestBorderCreator < Test::Unit::TestCase
def test_draw
5.times do
- @ws.add_row [1,2,3,4,5]
+ @ws.add_row [1, 2, 3, 4, 5]
end
bc = Axlsx::BorderCreator.new(worksheet: @ws, cells: @ws["A1:C3"], edges: ["top", :left], style: :thick, color: "ffffff")
diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb
index 884d9e01..2c67fed7 100644
--- a/test/workbook/worksheet/tc_break.rb
+++ b/test/workbook/worksheet/tc_break.rb
@@ -8,7 +8,7 @@ class TestBreak < Test::Unit::TestCase
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
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index af3699ad..a4aab11c 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -4,10 +4,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"]
@@ -47,8 +47,8 @@ class TestCell < Test::Unit::TestCase
end
def test_r_abs
- assert_equal(@c.r_abs,"$A$1", "calculate absolute cell reference")
- assert_equal(@cAA.r_abs,"$AA$2", "needs to accept multi-digit columns")
+ assert_equal(@c.r_abs, "$A$1", "calculate absolute cell reference")
+ assert_equal(@cAA.r_abs, "$AA$2", "needs to accept multi-digit columns")
end
def test_name
@@ -58,7 +58,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)
end
@@ -90,8 +90,8 @@ class TestCell < Test::Unit::TestCase
end
def test_style
- assert_raise(ArgumentError, "must reject invalid style indexes") { @[email protected] }
- assert_nothing_raised("must allow valid style index changes") {@c.style=1}
+ assert_raise(ArgumentError, "must reject invalid style indexes") { @c.style = @c.row.worksheet.workbook.styles.cellXfs.size }
+ assert_nothing_raised("must allow valid style index changes") { @c.style = 1 }
assert_equal(@c.style, 1)
end
@@ -99,7 +99,7 @@ class TestCell < Test::Unit::TestCase
assert_raise(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array }
assert_nothing_raised("type can be changed") { @c.type = :string }
assert_equal(@c.value, "1.0", "changing type casts the value")
- assert_equal(:float, @row.add_cell(1.0/10**7).type, 'properly identify exponential floats as float type')
+ assert_equal(:float, @row.add_cell(1.0 / 10**7).type, 'properly identify exponential floats as float type')
assert_equal(@row.add_cell(Time.now).type, :time, 'time should be time')
assert_equal(@row.add_cell(Date.today).type, :date, 'date should be date')
assert_equal(@row.add_cell(true).type, :boolean, 'boolean should be boolean')
@@ -133,7 +133,7 @@ class TestCell < Test::Unit::TestCase
assert_equal(@c.send(:cell_type_from_value, -1), :integer)
assert_equal(@c.send(:cell_type_from_value, true), :boolean)
assert_equal(@c.send(:cell_type_from_value, false), :boolean)
- assert_equal(@c.send(:cell_type_from_value, 1.0/10**6), :float)
+ assert_equal(@c.send(:cell_type_from_value, 1.0 / 10**6), :float)
assert_equal(@c.send(:cell_type_from_value, Axlsx::RichText.new), :richtext)
assert_equal(:iso_8601, @c.send(:cell_type_from_value, '2008-08-30T01:45:36.123+09:00'))
end
@@ -255,7 +255,7 @@ class TestCell < Test::Unit::TestCase
assert_raise(ArgumentError) { @c.u = -1.1 }
assert_nothing_raised { @c.u = :single }
assert_equal(@c.u, :single)
- doc = Nokogiri::XML(@c.to_xml_string(1,1))
+ doc = Nokogiri::XML(@c.to_xml_string(1, 1))
assert(doc.xpath('//u[@val="single"]'))
end
@@ -339,13 +339,13 @@ class TestCell < Test::Unit::TestCase
end
def test_to_xml_string
- c_xml = Nokogiri::XML(@c.to_xml_string(1,1))
+ c_xml = Nokogiri::XML(@c.to_xml_string(1, 1))
assert_equal(c_xml.xpath("/c[@s=1]").size, 1)
end
def test_to_xml_string_nil
@c.value = nil
- c_xml = Nokogiri::XML(@c.to_xml_string(1,1))
+ c_xml = Nokogiri::XML(@c.to_xml_string(1, 1))
assert_equal(c_xml.xpath("/c[@s=1]").size, 1)
end
@@ -357,7 +357,7 @@ class TestCell < Test::Unit::TestCase
@c.value = "a"
@c.font_name = 'arial'
@c.color = 'FF0000'
- c_xml = Nokogiri::XML(@c.to_xml_string(1,1))
+ c_xml = Nokogiri::XML(@c.to_xml_string(1, 1))
assert(c_xml.xpath("//b").any?)
end
diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb
index 2f31d7a2..80b228d0 100644
--- a/test/workbook/worksheet/tc_col.rb
+++ b/test/workbook/worksheet/tc_col.rb
@@ -6,10 +6,10 @@ 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
- options.each{ |key, value| assert_equal(col.send(key.to_sym), value) }
+ options.each { |key, value| assert_equal(col.send(key.to_sym), value) }
end
def test_min_max_required
diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb
index 7f9e5def..073cd71f 100644
--- a/test/workbook/worksheet/tc_color_scale.rb
+++ b/test/workbook/worksheet/tc_color_scale.rb
@@ -21,7 +21,7 @@ class TestColorScale < Test::Unit::TestCase
first = Axlsx::ColorScale.default_cfvos.first
second = Axlsx::ColorScale.default_cfvos.last
assert_equal 'FFFF7128', first[:color]
- assert_equal :min,first[:type]
+ assert_equal :min, first[:type]
assert_equal 0, first[:val]
assert_equal 'FFFFEF9C', second[:color]
@@ -30,7 +30,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]
assert_equal color_scale.value_objects.first.type, first_def[:type]
@@ -39,15 +39,15 @@ class TestColorScale < Test::Unit::TestCase
def test_add
@color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE"
- assert_equal(@color_scale.value_objects.size,3)
- assert_equal(@color_scale.colors.size,3)
+ assert_equal(@color_scale.value_objects.size, 3)
+ assert_equal(@color_scale.colors.size, 3)
end
def test_delete_at
@color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE"
- assert_nothing_raised {@color_scale.delete_at 2}
- assert_equal(@color_scale.value_objects.size,2)
- assert_equal(@color_scale.colors.size,2)
+ assert_nothing_raised { @color_scale.delete_at 2 }
+ assert_equal(@color_scale.value_objects.size, 2)
+ assert_equal(@color_scale.colors.size, 2)
end
def test_to_xml_string
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb
index 44a637e6..cbd93f01 100644
--- a/test/workbook/worksheet/tc_comment.rb
+++ b/test/workbook/worksheet/tc_comment.rb
@@ -47,7 +47,7 @@ class TestComment < Test::Unit::TestCase
assert_equal(pos[0], @c1.vml_shape.left_column)
assert(@c1.vml_shape.top_row == pos[1])
assert_equal(pos[0] + 2, @c1.vml_shape.right_column)
- assert(@c1.vml_shape.bottom_row == pos[1]+4)
+ assert(@c1.vml_shape.bottom_row == pos[1] + 4)
end
def test_to_xml_string
diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb
index 6b07b465..276dd3b0 100644
--- a/test/workbook/worksheet/tc_comments.rb
+++ b/test/workbook/worksheet/tc_comments.rb
@@ -19,7 +19,7 @@ class TestComments < Test::Unit::TestCase
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_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(@ws.comments.size, 3)
end
@@ -33,7 +33,7 @@ class TestComments < Test::Unit::TestCase
end
def test_pn
- assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index+1).to_s)
+ assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index + 1).to_s)
end
def test_index
diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb
index cc885255..dcbb3ca6 100644
--- a/test/workbook/worksheet/tc_conditional_formatting.rb
+++ b/test/workbook/worksheet/tc_conditional_formatting.rb
@@ -3,14 +3,14 @@ require 'tc_helper.rb'
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)
end
@@ -25,17 +25,17 @@ class TestConditionalFormatting < Test::Unit::TestCase
data_bar = Axlsx::DataBar.new :color => "FFFF0000"
icon_set = Axlsx::IconSet.new :iconSet => "5Rating"
- cfr = Axlsx::ConditionalFormattingRule.new( { :type => :containsText, :text => "TRUE",
+ 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})
+ :icon_set => icon_set })
assert(cfr.data_bar.is_a?(Axlsx::DataBar))
assert(cfr.icon_set.is_a?(Axlsx::IconSet))
assert(cfr.color_scale.is_a?(Axlsx::ColorScale))
- cfs = @ws.add_conditional_formatting( "B2:B2", [cfr])
+ cfs = @ws.add_conditional_formatting("B2:B2", [cfr])
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)
assert doc.xpath(".//conditionalFormatting//cfRule[@type='containsText'][@dxfId=0][@priority=1]//formula='NOT(ISERROR(SEARCH(\"FALSE\",AB1)))'")
@@ -68,12 +68,12 @@ class TestConditionalFormatting < Test::Unit::TestCase
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",
+ 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}])
+ :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)
assert doc.xpath(".//conditionalFormatting//cfRule[@type='containsText'][@dxfId=0][@priority=1]//formula='NOT(ISERROR(SEARCH(\"FALSE\",AB1)))'")
@@ -102,11 +102,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,
+ 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"})
+ :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)
assert 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']//formula=0.0")
@@ -126,7 +126,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'")
assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='between']//xmlns:formula='5'")
diff --git a/test/workbook/worksheet/tc_data_bar.rb b/test/workbook/worksheet/tc_data_bar.rb
index 65995dd2..aa39c48b 100644
--- a/test/workbook/worksheet/tc_data_bar.rb
+++ b/test/workbook/worksheet/tc_data_bar.rb
@@ -12,26 +12,26 @@ 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)
end
def test_minLength
assert_raise(ArgumentError) { @data_bar.minLength = :invalid_type }
- assert_nothing_raised { @data_bar.minLength = 0}
+ assert_nothing_raised { @data_bar.minLength = 0 }
assert_equal(@data_bar.minLength, 0)
end
def test_maxLength
assert_raise(ArgumentError) { @data_bar.maxLength = :invalid_type }
- assert_nothing_raised { @data_bar.maxLength = 0}
+ assert_nothing_raised { @data_bar.maxLength = 0 }
assert_equal(@data_bar.maxLength, 0)
end
def test_showValue
assert_raise(ArgumentError) { @data_bar.showValue = :invalid_type }
- assert_nothing_raised { @data_bar.showValue = false}
+ assert_nothing_raised { @data_bar.showValue = false }
assert_equal(@data_bar.showValue, false)
end
diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb
index 0d9a2eb0..59fd34f6 100644
--- a/test/workbook/worksheet/tc_data_validation.rb
+++ b/test/workbook/worksheet/tc_data_validation.rb
@@ -12,7 +12,7 @@ class TestDataValidation < Test::Unit::TestCase
@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}
+ @symbol_options = { :errorStyle => :warning, :operator => :lessThan, :type => :whole }
@options = @boolean_options.merge(@nil_options).merge(@type_option).merge(@error_style_option)
@@ -163,11 +163,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 = 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'})
+ :prompt => 'Only values between 5 and 10' })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -192,11 +192,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_list_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"data_validation"
+ @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})
+ :prompt => 'Only values from list', :hideDropDown => true })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -216,11 +216,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_custom_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"data_validation"
+ @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'})
+ :prompt => 'Only values corresponding formula' })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -239,15 +239,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 = 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'})
+ :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})
+ :prompt => 'Only values from list', :hideDropDown => true })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb
index 393a9d1a..cb139d45 100644
--- a/test/workbook/worksheet/tc_date_time_converter.rb
+++ b/test/workbook/worksheet/tc_date_time_converter.rb
@@ -114,8 +114,8 @@ class TestDateTimeConverter < Test::Unit::TestCase
local = Time.parse "2012-01-01 09:00:00 +0900"
assert_equal local, utc
- assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f/86400, Axlsx::DateTimeConverter::time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc)
Axlsx::Workbook.date1904 = true
- assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f/86400, Axlsx::DateTimeConverter::time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc)
end
end
diff --git a/test/workbook/worksheet/tc_icon_set.rb b/test/workbook/worksheet/tc_icon_set.rb
index 483de228..3a4079bf 100644
--- a/test/workbook/worksheet/tc_icon_set.rb
+++ b/test/workbook/worksheet/tc_icon_set.rb
@@ -14,25 +14,25 @@ class TestIconSet < Test::Unit::TestCase
def test_icon_set
assert_raise(ArgumentError) { @icon_set.iconSet = "invalid_value" }
- assert_nothing_raised { @icon_set.iconSet = "5Rating"}
+ assert_nothing_raised { @icon_set.iconSet = "5Rating" }
assert_equal(@icon_set.iconSet, "5Rating")
end
def test_percent
assert_raise(ArgumentError) { @icon_set.percent = :invalid_type }
- assert_nothing_raised { @icon_set.percent = false}
+ assert_nothing_raised { @icon_set.percent = false }
assert_equal(@icon_set.percent, false)
end
def test_showValue
assert_raise(ArgumentError) { @icon_set.showValue = :invalid_type }
- assert_nothing_raised { @icon_set.showValue = false}
+ assert_nothing_raised { @icon_set.showValue = false }
assert_equal(@icon_set.showValue, false)
end
def test_reverse
assert_raise(ArgumentError) { @icon_set.reverse = :invalid_type }
- assert_nothing_raised { @icon_set.reverse = false}
+ assert_nothing_raised { @icon_set.reverse = false }
assert_equal(@icon_set.reverse, false)
end
diff --git a/test/workbook/worksheet/tc_page_margins.rb b/test/workbook/worksheet/tc_page_margins.rb
index c1f2a626..ba532e7f 100644
--- a/test/workbook/worksheet/tc_page_margins.rb
+++ b/test/workbook/worksheet/tc_page_margins.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
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
diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb
index c7cec18b..b7a36600 100644
--- a/test/workbook/worksheet/tc_page_setup.rb
+++ b/test/workbook/worksheet/tc_page_setup.rb
@@ -132,9 +132,9 @@ class TestPageSetup < Test::Unit::TestCase
fits = @ps.fit_to(:width => 1)
assert_equal([1, 999], fits)
fits = @ps.fit_to :height => 1
- assert_equal(fits, [999,1])
+ assert_equal(fits, [999, 1])
fits = @ps.fit_to :height => 7, :width => 2
assert_equal(fits, [2, 7])
- 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_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb
index 85aa14cd..83f8fce6 100644
--- a/test/workbook/worksheet/tc_pivot_table.rb
+++ b/test/workbook/worksheet/tc_pivot_table.rb
@@ -16,7 +16,7 @@ class TestPivotTable < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet
- @ws << ["Year","Month","Region", "Type", "Sales"]
+ @ws << ["Year", "Month", "Region", "Type", "Sales"]
@ws << [2012, "Nov", "East", "Soda", "12345"]
end
@@ -54,21 +54,21 @@ class TestPivotTable < Test::Unit::TestCase
end
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']
@@ -79,33 +79,33 @@ 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']
+ pt.rows = ['Year', 'Month']
end
assert_equal(['Year'], pivot_table.no_subtotals_on_headers)
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']
+ pt.rows = ['Year', 'Month']
end
- assert_equal({'Month' => :ascending}, pivot_table.sort_on_headers)
+ assert_equal({ 'Month' => :ascending }, pivot_table.sort_on_headers)
- pivot_table.sort_on_headers = {'Month' => :descending}
- assert_equal({'Month' => :descending}, pivot_table.sort_on_headers)
+ pivot_table.sort_on_headers = { 'Month' => :descending }
+ assert_equal({ 'Month' => :descending }, pivot_table.sort_on_headers)
shared_test_pivot_table_xml_validity(pivot_table)
end
def test_header_indices
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5')
- assert_equal(0, pivot_table.header_index_of('Year' ))
- assert_equal(1, pivot_table.header_index_of('Month' ))
- assert_equal(2, pivot_table.header_index_of('Region' ))
- assert_equal(3, pivot_table.header_index_of('Type' ))
- assert_equal(4, pivot_table.header_index_of('Sales' ))
+ assert_equal(0, pivot_table.header_index_of('Year'))
+ assert_equal(1, pivot_table.header_index_of('Month'))
+ assert_equal(2, pivot_table.header_index_of('Region'))
+ assert_equal(3, pivot_table.header_index_of('Type'))
+ assert_equal(4, pivot_table.header_index_of('Sales'))
assert_equal(nil, pivot_table.header_index_of('Missing'))
assert_equal(%w(A1 B1 C1 D1 E1), pivot_table.header_cell_refs)
end
@@ -129,7 +129,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']
@@ -140,14 +140,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)
assert_equal('4', doc.at_css('dataFields dataField')['numFmtId'], 'adding format options to pivot_table')
@@ -159,9 +159,9 @@ class TestPivotTable < Test::Unit::TestCase
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
pt.rows = ["Date", "Name"]
pt.data = [
- {ref: "Gross amount", num_fmt: 2},
- {ref: "Net amount", num_fmt: 2},
- {ref: "Margin", num_fmt: 2}
+ { ref: "Gross amount", num_fmt: 2 },
+ { ref: "Net amount", num_fmt: 2 },
+ { ref: "Margin", num_fmt: 2 }
]
end
@@ -177,8 +177,8 @@ class TestPivotTable < Test::Unit::TestCase
assert_equal('-2', doc.at_css('colFields field')['x'])
assert_equal('3', doc.at_css('colItems')['count'])
- assert_equal( 3, doc.at_css('colItems').children.size)
- assert_nil( doc.at_css('colItems i')['x'])
+ assert_equal(3, doc.at_css('colItems').children.size)
+ assert_nil(doc.at_css('colItems i')['x'])
assert_equal('1', doc.at_css('colItems i[i=1] x')['v'])
assert_equal('2', doc.at_css('colItems i[i=2] x')['v'])
end
@@ -189,7 +189,7 @@ class TestPivotTable < Test::Unit::TestCase
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
pt.rows = ["Date", "Name"]
pt.data = [
- {ref: "Gross amount", num_fmt: 2}
+ { ref: "Gross amount", num_fmt: 2 }
]
end
diff --git a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb
index 37d7e485..2127c4b3 100644
--- a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb
+++ b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb
@@ -5,7 +5,7 @@ class TestPivotTableCacheDefinition < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet
5.times do
- @ws << ["aa","aa","aa","aa"]
+ @ws << ["aa", "aa", "aa", "aa"]
end
@pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5')
@cache_definition = @pivot_table.cache_definition
diff --git a/test/workbook/worksheet/tc_protected_range.rb b/test/workbook/worksheet/tc_protected_range.rb
index 52d07d77..6d609097 100644
--- a/test/workbook/worksheet/tc_protected_range.rb
+++ b/test/workbook/worksheet/tc_protected_range.rb
@@ -2,11 +2,11 @@ require 'tc_helper.rb'
class TestProtectedRange < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
- @ws = @p.workbook.add_worksheet { |sheet| sheet.add_row [1,2,3,4,5,6,7,8,9] }
+ @ws = @p.workbook.add_worksheet { |sheet| sheet.add_row [1, 2, 3, 4, 5, 6, 7, 8, 9] }
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 1bd3ec76..34117b1b 100644
--- a/test/workbook/worksheet/tc_rich_text.rb
+++ b/test/workbook/worksheet/tc_rich_text.rb
@@ -8,7 +8,7 @@ class RichText < Test::Unit::TestCase
@rt = Axlsx::RichText.new
b = true
(0..26).each 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
@@ -22,7 +22,7 @@ class RichText < Test::Unit::TestCase
assert_equal(rt_direct.runs.length, 1)
assert_equal(rt_indirect.runs.length, 1)
row = @ws.add_row [rt_direct, rt_indirect]
- assert_equal(row[0].to_xml_string(0,0), row[1].to_xml_string(0,0))
+ assert_equal(row[0].to_xml_string(0, 0), row[1].to_xml_string(0, 0))
end
def test_textruns
@@ -39,6 +39,6 @@ class RichText < Test::Unit::TestCase
row_rt = @ws.add_row [rt]
row_imp = @ws.add_row ['a']
row_imp[0].b = true
- assert_equal(row_rt[0].to_xml_string(0,0), row_imp[0].to_xml_string(0,0))
+ assert_equal(row_rt[0].to_xml_string(0, 0), row_imp[0].to_xml_string(0, 0))
end
end
diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb
index 39919a31..d21329a9 100644
--- a/test/workbook/worksheet/tc_rich_text_run.rb
+++ b/test/workbook/worksheet/tc_rich_text_run.rb
@@ -106,7 +106,7 @@ class RichTextRun < Test::Unit::TestCase
assert_raise(ArgumentError) { @c.u = -1.1 }
assert_nothing_raised { @c.u = :single }
assert_equal(@c.u, :single)
- doc = Nokogiri::XML(@c.to_xml_string(1,1))
+ doc = Nokogiri::XML(@c.to_xml_string(1, 1))
assert(doc.xpath('//u[@val="single"]'))
end
@@ -141,7 +141,7 @@ class RichTextRun < Test::Unit::TestCase
end
def test_multiline_autowidth
- wrap = @p.workbook.styles.add_style({:alignment => {:wrap_text => 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
diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb
index 900e751e..29c4415b 100644
--- a/test/workbook/worksheet/tc_row.rb
+++ b/test/workbook/worksheet/tc_row.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
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
@@ -15,19 +15,19 @@ 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)
end
def test_style
- r = @ws.add_row([1,2,3,4,5])
- r.style=1
- r.cells.each { |c| assert_equal(c.style,1) }
+ r = @ws.add_row([1, 2, 3, 4, 5])
+ r.style = 1
+ r.cells.each { |c| assert_equal(c.style, 1) }
end
def test_color
- r = @ws.add_row([1,2,3,4,5])
+ r = @ws.add_row([1, 2, 3, 4, 5])
r.color = "FF00FF00"
r.cells.each { |c| assert_equal(c.color.rgb, "FF00FF00") }
end
@@ -48,12 +48,12 @@ 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(r.cells.size, 3)
r.cells.each do |c|
assert_equal(c.style, 1)
end
- r = @ws.add_row [1,2,3], :style=>[1]
+ r = @ws.add_row [1, 2, 3], :style => [1]
assert_equal(r.cells.first.style, 1, "only apply style to cells with at the same index of of the style array")
assert_equal(r.cells.last.style, 0, "only apply style to cells with at the same index of of the style array")
end
@@ -135,7 +135,7 @@ class TestRow < Test::Unit::TestCase
def test_offsets
offset = 3
- values = [1,2,3,4,5]
+ values = [1, 2, 3, 4, 5]
r = @ws.add_row(values, offset: offset, style: 1)
r.cells.each_with_index do |c, index|
assert_equal(c.style, index < offset ? 0 : 1)
@@ -145,11 +145,11 @@ class TestRow < Test::Unit::TestCase
def test_offsets_with_styles
offset = 3
- values = [1,2,3,4,5]
- styles = (1..5).map{ @ws.workbook.styles.add_style }
+ values = [1, 2, 3, 4, 5]
+ styles = (1..5).map { @ws.workbook.styles.add_style }
r = @ws.add_row(values, offset: offset, style: styles)
r.cells.each_with_index do |c, index|
- assert_equal(c.style, index < offset ? 0 : styles[index-offset])
+ assert_equal(c.style, index < offset ? 0 : styles[index - offset])
assert_equal(c.value, index < offset ? nil : values[index - offset])
end
end
diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb
index ef4eb0d8..48643bc6 100644
--- a/test/workbook/worksheet/tc_sheet_format_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_format_pr.rb
@@ -45,31 +45,31 @@ class TestSheetFormatPr < Test::Unit::TestCase
def test_default_row_height
assert_raise(ArgumentError) { @sheet_format_pr.default_row_height = :foo }
- assert_nothing_raised { @sheet_format_pr.default_row_height= 1.0 }
+ assert_nothing_raised { @sheet_format_pr.default_row_height = 1.0 }
end
def test_default_col_width
- assert_raise(ArgumentError) { @sheet_format_pr.default_col_width= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.default_col_width = :foo }
assert_nothing_raised { @sheet_format_pr.default_col_width = 1.0 }
end
def test_custom_height
- assert_raise(ArgumentError) { @sheet_format_pr.custom_height= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.custom_height = :foo }
assert_nothing_raised { @sheet_format_pr.custom_height = true }
end
def test_zero_height
- assert_raise(ArgumentError) { @sheet_format_pr.zero_height= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.zero_height = :foo }
assert_nothing_raised { @sheet_format_pr.zero_height = true }
end
def test_thick_top
- assert_raise(ArgumentError) { @sheet_format_pr.thick_top= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.thick_top = :foo }
assert_nothing_raised { @sheet_format_pr.thick_top = true }
end
def test_thick_bottom
- assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom = :foo }
assert_nothing_raised { @sheet_format_pr.thick_bottom = true }
end
diff --git a/test/workbook/worksheet/tc_sheet_pr.rb b/test/workbook/worksheet/tc_sheet_pr.rb
index f6ffcfdb..70ce0428 100644
--- a/test/workbook/worksheet/tc_sheet_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_pr.rb
@@ -20,7 +20,7 @@ class TestSheetPr < Test::Unit::TestCase
def test_initialization
@options.each do |key, value|
- if key==:tab_color
+ if key == :tab_color
stored_value = @sheet_pr.send(key)
assert_equal Axlsx::Color, stored_value.class
assert_equal value, stored_value.rgb
diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb
index 26297bc4..8d5452cc 100644
--- a/test/workbook/worksheet/tc_sheet_protection.rb
+++ b/test/workbook/worksheet/tc_sheet_protection.rb
@@ -55,7 +55,7 @@ class TestSheetProtection < Test::Unit::TestCase
@sp.password = 'fish' # -> CA3F
doc = Nokogiri::XML(@sp.to_xml_string)
@options.each do |key, value|
- assert(doc.xpath("//sheetProtection[@#{key.to_s.gsub(/_(.)/){ $1.upcase }}='#{value}']"))
+ assert(doc.xpath("//sheetProtection[@#{key.to_s.gsub(/_(.)/) { $1.upcase }}='#{value}']"))
end
end
end
diff --git a/test/workbook/worksheet/tc_table.rb b/test/workbook/worksheet/tc_table.rb
index 1a90f0bc..7a2e5987 100644
--- a/test/workbook/worksheet/tc_table.rb
+++ b/test/workbook/worksheet/tc_table.rb
@@ -5,7 +5,7 @@ class TestTable < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet
40.times do
- @ws << ["aa","aa","aa","aa","aa","aa"]
+ @ws << ["aa", "aa", "aa", "aa", "aa", "aa"]
end
end
diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb
index 19beaaba..2067959c 100644
--- a/test/workbook/worksheet/tc_table_style_info.rb
+++ b/test/workbook/worksheet/tc_table_style_info.rb
@@ -7,7 +7,7 @@ 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')
+ @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,
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index 8475f5aa..bae9f904 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -29,7 +29,7 @@ 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
@@ -107,15 +107,15 @@ class TestWorksheet < Test::Unit::TestCase
def test_no_autowidth
@ws.workbook.use_autowidth = false
- @ws.add_row [1,2,3,4]
+ @ws.add_row [1, 2, 3, 4]
assert_equal(@ws.column_info[0].width, nil)
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'}
+ 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.keys.each do |key|
assert_equal(page_margins[key], optioned.page_margins.send(key))
@@ -175,8 +175,8 @@ class TestWorksheet < Test::Unit::TestCase
range = @ws["A1:C2"]
first_row = @ws[0]
last_row = @ws[1]
- assert_equal(@ws.rows[0],first_row)
- assert_equal(@ws.rows[1],last_row)
+ assert_equal(@ws.rows[0], first_row)
+ assert_equal(@ws.rows[1], last_row)
assert_equal(range.size, 6)
assert_equal(range.first, @ws.rows.first.cells.first)
assert_equal(range.last, @ws.rows.last.cells.last)
@@ -184,7 +184,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_add_row
assert(@ws.rows.empty?, "sheet has no rows by default")
- r = @ws.add_row([1,2,3])
+ r = @ws.add_row([1, 2, 3])
assert_equal(@ws.rows.size, 1, "add_row adds a row")
assert_equal(@ws.rows.first, r, "the row returned is the row added")
end
@@ -227,11 +227,11 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_col_style
- @ws.add_row [1,2,3,4]
- @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.add_row [1, 2, 3, 4]
+ @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.rows[(1..-1)].each do |r|
assert_equal(r.cells[1].style, 1)
assert_equal(r.cells[2].style, 1)
@@ -241,41 +241,41 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_col_style_with_empty_column
- @ws.add_row [1,2,3,4]
+ @ws.add_row [1, 2, 3, 4]
@ws.add_row [1]
- @ws.add_row [1,2,3,4]
- assert_nothing_raised {@ws.col_style(1, 1)}
+ @ws.add_row [1, 2, 3, 4]
+ assert_nothing_raised { @ws.col_style(1, 1) }
end
def test_cols
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3]
- @ws.add_row [1,2,3,4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3]
+ @ws.add_row [1, 2, 3, 4]
c = @ws.cols[1]
assert_equal(c.size, 4)
assert_equal(c[0].value, 2)
end
def test_cols_with_block
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
@ws.add_row [1]
- cols = @ws.cols {|row, column| :foo }
+ cols = @ws.cols { |row, column| :foo }
assert_equal(:foo, cols[1][1])
end
def test_row_style
- @ws.add_row [1,2,3,4]
- @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.add_row [1, 2, 3, 4]
+ @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.rows[1].cells[(1..-1)].each do |c|
assert_equal(c.style, 1)
end
assert_equal(@ws.rows[1].cells[0].style, 0)
assert_equal(@ws.rows[2].cells[1].style, 0)
- @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(c.style, 1)
@@ -290,7 +290,7 @@ class TestWorksheet < Test::Unit::TestCase
# end
def test_to_xml_string_dimensions
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:dimension[@ref="A1:C1"]').size, 1)
end
@@ -414,7 +414,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_to_xml_string
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
doc = Nokogiri::XML(@ws.to_xml_string)
- assert(schema.validate(doc).map{ |e| puts e.message; e }.empty?, "error free validation")
+ assert(schema.validate(doc).map { |e| puts e.message; e }.empty?, "error free validation")
end
def test_styles
@@ -424,7 +424,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_to_xml_string_with_illegal_chars
old = Axlsx::trust_input
Axlsx::trust_input = false
- nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
+ nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
@ws.add_row [nasties]
assert_equal(0, @ws.rows.last.cells.last.value.index("\v"))
assert_equal(nil, @ws.to_xml_string.index("\v"))
@@ -455,7 +455,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_relationships
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
assert(@ws.relationships.empty?, "No Drawing relationship until you add a chart")
@ws.add_chart Axlsx::Pie3DChart
assert_equal(@ws.relationships.size, 1, "adding a chart creates the relationship")
@@ -529,14 +529,14 @@ class TestWorksheet < Test::Unit::TestCase
def test_protect_range_with_cells
@ws.add_row [1, 2, 3]
- assert_nothing_raised {@ws.protect_range(@ws.rows.first.cells) }
+ assert_nothing_raised { @ws.protect_range(@ws.rows.first.cells) }
assert_equal('A1:C1', @ws.send(:protected_ranges).last.sqref)
end
def test_merge_cells
- @ws.add_row [1,2,3]
- @ws.add_row [4,5,6]
- @ws.add_row [7,8,9]
+ @ws.add_row [1, 2, 3]
+ @ws.add_row [4, 5, 6]
+ @ws.add_row [7, 8, 9]
@ws.merge_cells "A1:A2"
@ws.merge_cells "B2:C3"
@ws.merge_cells @ws.rows.last.cells[(0..1)]
@@ -554,12 +554,12 @@ class TestWorksheet < Test::Unit::TestCase
def test_auto_filter
assert(@ws.auto_filter.range.nil?)
- assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
+ assert(@wb.defined_names.none? { |defined_name| defined_name.name == '_xlnm._FilterDatabase' })
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
@ws.auto_filter.range = "A1:D9"
assert_equal(@ws.auto_filter.range, "A1:D9")
@ws.to_xml_string
- assert(@wb.defined_names.any?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
+ assert(@wb.defined_names.any? { |defined_name| defined_name.name == '_xlnm._FilterDatabase' })
end
def test_auto_filter_assign
@@ -567,7 +567,7 @@ class TestWorksheet < Test::Unit::TestCase
assert(@ws.auto_filter.range.nil?)
assert(other_ws.auto_filter.range.nil?)
- assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
+ assert(@wb.defined_names.none? { |defined_name| defined_name.name == '_xlnm._FilterDatabase' })
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
@ws.auto_filter = "A1:D9"
@@ -579,7 +579,7 @@ class TestWorksheet < Test::Unit::TestCase
@ws.to_xml_string
other_ws.to_xml_string
- filter_database = @wb.defined_names.select{|defined_name| defined_name.name=='_xlnm._FilterDatabase'}
+ filter_database = @wb.defined_names.select { |defined_name| defined_name.name == '_xlnm._FilterDatabase' }
assert_equal(2, filter_database.size)
assert_equal(@ws.index, filter_database[0].local_sheet_id)
assert_equal(other_ws.index, filter_database[1].local_sheet_id)
@@ -593,7 +593,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_outline_level_rows
- 3.times { @ws.add_row [1,2,3] }
+ 3.times { @ws.add_row [1, 2, 3] }
@ws.outline_level_rows 0, 2
assert_equal(1, @ws.rows[0].outline_level)
assert_equal(true, @ws.rows[2].hidden)
@@ -601,7 +601,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_outline_level_columns
- 3.times { @ws.add_row [1,2,3] }
+ 3.times { @ws.add_row [1, 2, 3] }
@ws.outline_level_columns 0, 2
assert_equal(1, @ws.column_info[0].outline_level)
assert_equal(true, @ws.column_info[2].hidden)
@@ -717,16 +717,16 @@ class TestWorksheet < Test::Unit::TestCase
wb.add_worksheet do |sheet|
20.times.each do
- sheet.add_row [1,2,3,4,5]
+ sheet.add_row [1, 2, 3, 4, 5]
end
sheet.add_border "B2:D5"
- sheet.add_border ["C3:C4", "D3:D4", "A2"], {color: "FF00000"}
+ sheet.add_border ["C3:C4", "D3:D4", "A2"], { color: "FF00000" }
sheet.add_border "B10:E10", [:top, :bottom, :left, :right]
sheet.add_border "B12:E12", :all
sheet.add_border "B14:E14", Axlsx::Border::EDGES
- sheet.add_border "B16:E16", {edges: :all, style: :thick}
- sheet.add_border "B18:E18", {edges: [:top], style: :thick, color: "FFFFF00"}
+ sheet.add_border "B16:E16", { edges: :all, style: :thick }
+ sheet.add_border "B18:E18", { edges: [:top], style: :thick, color: "FFFFF00" }
end
wb.apply_styles
@@ -786,7 +786,7 @@ class TestWorksheet < Test::Unit::TestCase
sz: 11,
family: 1
}
- assert_equal b2_cell_style, wb.styles.style_index.values.find{|x| x == b2_cell_style}
+ assert_equal b2_cell_style, wb.styles.style_index.values.find { |x| x == b2_cell_style }
d3_cell_style = {
border: {
@@ -799,7 +799,7 @@ class TestWorksheet < Test::Unit::TestCase
sz: 11,
family: 1
}
- assert_equal d3_cell_style, wb.styles.style_index.values.find{|x| x == d3_cell_style}
+ assert_equal d3_cell_style, wb.styles.style_index.values.find { |x| x == d3_cell_style }
end
def test_mixed_borders_1
@@ -872,7 +872,7 @@ class TestWorksheet < Test::Unit::TestCase
wb.styles.fonts[0].sz = 12
wb.add_worksheet do |sheet|
- sheet.add_row [1,2,3]
+ sheet.add_row [1, 2, 3]
sheet.add_style "A1:C1", { color: "FFFFFF" }
end