Sha256: 7d6e9d5abb661a833e4db216027d26366358ef5ae9c27f625e095be23cef8e86

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Summarization do
  subject { relation.summarize(summarize_per) { |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(:summarize_per) { 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 a smaller set' do
    let(:summarize_per) { Relation.new(by_header, [ [ 'Dan Kubb' ] ]) }

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

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

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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
axiom-0.1.0 spec/integration/axiom/algebra/summarization_spec.rb
veritas-0.0.7 spec/integration/veritas/algebra/summarization_spec.rb
veritas-0.0.6 spec/integration/veritas/algebra/summarization_spec.rb
veritas-0.0.5 spec/integration/veritas/algebra/summarization_spec.rb
veritas-0.0.4 spec/integration/veritas/algebra/summarization_spec.rb