Sha256: 214cd111386c1698af2919a7fd25c13fa6d8ece6047a069159126780479d34fc

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

require 'spec_helper'
module Alf
  module Engine
    describe Summarize::Cesure do

      let(:input) {[
        {:a => "via_method", :time => 1},
        {:a => "via_method", :time => 1},
        {:a => "via_method", :time => 2},
        {:a => "via_reader", :time => 4},
        {:a => "via_reader", :time => 2},
      ]}

      let(:expected) {[
        {:a => "via_method", :time_sum => 4, :time_max => 2},
        {:a => "via_reader", :time_sum => 6, :time_max => 4},
      ]}

      let(:aggs){Summarization.new(
        :time_sum => Aggregator.sum{ time },
        :time_max => Aggregator.max{ time }
      )} 

      it 'should summarize as expected' do
        sum = Summarize::Cesure.new(input, AttrList[:a], aggs, false)
        sum.to_a.should eq(expected)
      end

      it 'should support allbut summarization' do
        sum = Summarize::Cesure.new(input, AttrList[:time], aggs, true)
        sum.to_a.should eq(expected)
      end

    end 
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-engine/summarize/test_cesure.rb
alf-0.12.1 spec/unit/alf-engine/summarize/test_cesure.rb
alf-0.12.0 spec/unit/alf-engine/summarize/test_cesure.rb
alf-0.11.1 spec/unit/alf-engine/summarize/test_cesure.rb
alf-0.11.0 spec/unit/alf-engine/summarize/test_cesure.rb