"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/table_pivot_test.rb" between
ruport-1.7.1.tar.gz and ruport-1.8.0.tar.gz

About: Ruport (Ruby Reports) is a simple, extensible reporting system built for Rubyists. It provides tools for data acquisition, database interaction, formatting, and parsing/munging.

table_pivot_test.rb  (ruport-1.7.1):table_pivot_test.rb  (ruport-1.8.0)
skipping to change at line 24 skipping to change at line 24
def test_produces_correct_columns def test_produces_correct_columns
assert_equal(['a', 3, 4], @pivoted.column_names) assert_equal(['a', 3, 4], @pivoted.column_names)
end end
def test_produces_correct_full_table def test_produces_correct_full_table
expected = Ruport.Table("a",3,4) { |t| t << [1,6,7] << [2,8,9] } expected = Ruport.Table("a",3,4) { |t| t << [1,6,7] << [2,8,9] }
assert_equal(expected, @pivoted) assert_equal(expected, @pivoted)
end end
def test_pivot_empty_table
tab = Ruport.Table ["id", "num_sessions", "status", "diagnosis"]
tab << ["one", 10, :aborted, :good]
tab << ["two", 10, :success, :bad]
tab.pivot("status", :group_by=>"diagnosis", :values=>"num_sessions", :operat
ion=>:mean)
end
end end
class PivotConvertRowOrderToGroupOrderTest < Minitest::Test class PivotConvertRowOrderToGroupOrderTest < Minitest::Test
def convert(row_order) def convert(row_order)
Ruport::Data::Table::Pivot.row_order_to_group_order(row_order) Ruport::Data::Table::Pivot.row_order_to_group_order(row_order)
end end
def setup def setup
@group = mock('group') @group = mock('group')
skipping to change at line 58 skipping to change at line 65
assert_equal(['f1val', 'f2val'], converted.call(@group)) assert_equal(['f1val', 'f2val'], converted.call(@group))
end end
def test_proc_operating_on_row def test_proc_operating_on_row
converted = convert(proc {|row| row[:field1] }) converted = convert(proc {|row| row[:field1] })
@row.stubs(:[]).with(:field1).returns('f1val') @row.stubs(:[]).with(:field1).returns('f1val')
assert_equal('f1val', converted.call(@group)) assert_equal('f1val', converted.call(@group))
end end
def test_nil def test_nil
assert_equal(nil, convert(nil)) assert_nil convert(nil)
end end
end end
class PivotPreservesOrdering < Minitest::Test class PivotPreservesOrdering < Minitest::Test
def test_group_column_preserves_order_of_occurrence def test_group_column_preserves_order_of_occurrence
table = Ruport.Table('group', 'a', 'b') table = Ruport.Table('group', 'a', 'b')
[ [
[1, 0, 0], [1, 0, 0],
skipping to change at line 128 skipping to change at line 135
assert_equal(['group', 7, 8, 9], pivoted.column_names) assert_equal(['group', 7, 8, 9], pivoted.column_names)
end end
def test_preserves_ordering_on_calculated_column_with_proc_pivot_order def test_preserves_ordering_on_calculated_column_with_proc_pivot_order
table = Ruport.Table('group', 'a') table = Ruport.Table('group', 'a')
[ [
[1, 1], [2, 2], [3, 3] [1, 1], [2, 2], [3, 3]
].each {|e| table << e} ].each {|e| table << e}
table.add_column('pivotme') {|row| 10 - row.group.to_i} table.add_column('pivotme') {|row| 10 - row.group.to_i}
pivoted = table.pivot('pivotme', :group_by => 'group', :values => 'a', pivoted = table.pivot('pivotme', :group_by => 'group', :values => 'a',
:pivot_order => proc {|row, pivot| pivot }) :pivot_order => proc {|_row, pivot| pivot } )
assert_equal(['group', 7, 8, 9], pivoted.column_names) assert_equal(['group', 7, 8, 9], pivoted.column_names)
end end
end end
class TablePivotOperationTest < Minitest::Test class TablePivotOperationTest < Minitest::Test
def setup def setup
@rows = [ @rows = [
Ruport::Data::Record.new('Values' => 3), Ruport::Data::Record.new('Values' => 3),
Ruport::Data::Record.new('Values' => 9), Ruport::Data::Record.new('Values' => 9),
 End of changes. 3 change blocks. 
2 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)