Sha256: c198711994b1c1ff3041c4dec2bbecaafe66487854fae601827a9e9040107409

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Summarize do
        
      let(:operator_class){ Summarize }
      it_should_behave_like("An operator class")
        
      let(:input) {[
        {:a => "via_reader", :time => 2},
        {:a => "via_method", :time => 1},
        {:a => "via_method", :time => 2},
        {:a => "via_reader", :time => 4},
        {:a => "via_method", :time => 1},
      ]}
  
      let(:expected) {[
        {:a => "via_method", :time_sum => 4, :time_max => 2},
        {:a => "via_reader", :time_sum => 6, :time_max => 4},
      ]}
  
      subject{ operator.to_a }
  
      describe "When factored with commandline args" do
        let(:opts){ ["--by=a"] }
        let(:aggs){ ["time_sum", "sum(:time)", "time_max", "max(:time)"] }
        let(:operator){ Summarize.run(opts + ["--"] +aggs) }
        before{ operator.pipe(input) }
        it { should == expected }
      end
  
      describe "When factored with Lispy" do
        let(:aggs){{:time_sum => Aggregator.sum(:time),
                    :time_max => Aggregator.max(:time)}} 
        let(:operator){ Lispy.summarize(input, [:a], aggs) }
        it { should == expected }
      end
  
    end 
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.9.0 spec/operator/relational/summarize_spec.rb