Sha256: b94dbe3d08165c92fd488bd662f032988d070ba4b4ce2bb6f54314f90296ce00

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Summarization::Summary, '#call' do
  subject { object.call(tuple) }

  let(:object) { described_class.new(summarizer)           }
  let(:header) { Relation::Header.coerce([[:id, Integer]]) }
  let(:tuple)  { Tuple.new(header, [1])                    }

  context 'when the summarizer is a Proc' do
    let(:summarizer) { ->(accumulator, tuple) { accumulator.to_i.succ } }

    context 'when there is no summary' do
      it { should be_nil }
    end

    context 'when there is a summary' do
      before do
        object.summarize_by(tuple, tuple)
      end

      it { should == 1 }
    end
  end

  context 'when the summarizer is an aggregate function' do
    let(:summarizer) { header.first.mean }

    context 'when there is no summary' do
      it { should be_nil }
    end

    context 'when there is a summary' do
      before do
        object.summarize_by(tuple, tuple)
      end

      it { should == 1 }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/axiom/algebra/summarization/summary/call_spec.rb
axiom-0.1.1 spec/unit/axiom/algebra/summarization/summary/call_spec.rb