diff options
Diffstat (limited to 'test/workbook/worksheet/tc_pivot_table.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_pivot_table.rb | 54 |
1 files changed, 27 insertions, 27 deletions
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 |
