Sha256: 6a9127e313bc41a722b01c42a4e305b9149f5a1cb821934e501c9cf1ec466b37

Contents?: true

Size: 1004 Bytes

Versions: 4

Compression:

Stored size: 1004 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.new([ [ :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

4 entries across 4 versions & 1 rubygems

Version Path
veritas-0.0.7 spec/unit/veritas/algebra/summarization/summary/call_spec.rb
veritas-0.0.6 spec/unit/veritas/algebra/summarization/summary/call_spec.rb
veritas-0.0.5 spec/unit/veritas/algebra/summarization/summary/call_spec.rb
veritas-0.0.4 spec/unit/veritas/algebra/summarization/summary/call_spec.rb