Sha256: 11070fc289d1c4c02607a68c460813a22ba8cae68ff5110d944c3863a3490510

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe 'Veritas::Algebra::Summarization' do
  subject { relation.summarize(by) { |r| r.add(:count) { |accumulator, _| accumulator.to_i + 1 } } }

  let(:header)    { [ [ :name, String ], [ :qty, Integer ] ]                       }
  let(:relation)  { Relation.new(header, [ [ 'Dan Kubb', 1 ], [ 'John Doe', 1 ] ]) }
  let(:by_header) { header.values_at(0)                                            }

  context 'summarize on the same set' do
    let(:by) { Relation.new(by_header, [ [ 'Dan Kubb' ], [ 'John Doe' ] ]) }

    it 'returns a relation with a single tuple' do
      should == [ [ 'Dan Kubb', 1 ], [ 'John Doe', 1 ] ]
    end
  end

  context 'summarize on an smaller set' do
    let(:by) { Relation.new(by_header, [ [ 'Dan Kubb' ] ]) }

    it 'returns a relation with a single tuple' do
      should == [ [ 'Dan Kubb', 1 ] ]
    end
  end

  context 'summarize on an larger set' do
    let(:by) { Relation.new(by_header, [ [ 'Dan Kubb' ], [ 'Dane Largy' ] ]) }

    it 'returns a relation with a single tuple' do
      pending 'TODO: fix error when Proc-based aggregate functions can have a default accumulator specified' do
        should == [ [ 'Dan Kubb', 1 ], [ 'Dane Largy', 0 ] ]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/integration/veritas/algebra/summarization_spec.rb