Sha256: a7376b35f180997ce123f30e40947c2c4374951a722153cb08739cb91175d5a3

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

require 'spec_helper'
module Alf
  module Engine
    describe Aggregate do

      it 'should work on an empty operand' do
        Autonum.new(Leaf.new([]), Summarization[{}]).to_a.should eq([])
      end

      it 'should work on a non empty operand' do
        rel = Leaf.new [
          {:name => "Jones", :price => 12.0, :id => 1},
          {:name => "Smith", :price => 10.0, :id => 2}
        ]
        agg = Summarization[:size  => Aggregator.count,
                            :total => Aggregator.sum{|t| t.price }]
        exp = [
          {:size => 2, :total => 22.0}
        ]
        Aggregate.new(rel, agg).to_a.should eq(exp)
      end

    end
  end # module Engine
end # module Alf    

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-engine/test_aggregate.rb