Sha256: 30e802eb6bbfca4fb9d7df625eb366fbe4a4133f07baa5ab71d85f248c314dc0

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 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) { lambda { |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

1 entries across 1 versions & 1 rubygems

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