Sha256: 3e54c079fa85db8569d0407b8bfbe8df46bd800198cb52d9eb2ba9bacc293ebc

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Summarization, '#each' do
  subject { object.each { |tuple| yields << tuple } }

  let(:object)      { described_class.new(operand, operand.project([]), summarizers) }
  let(:operand)     { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ])           }
  let(:summarizers) { { :count => lambda { |acc, tuple| acc.to_i + 1 } }             }
  let(:yields)      { []                                                             }

  it_should_behave_like 'an #each method'

  it 'yields only tuples' do
    subject
    yields.each { |tuple| tuple.should be_instance_of(Tuple) }
  end

  it 'yields only tuples with the expected header' do
    subject
    yields.each { |tuple| tuple.header.should eql(object.header) }
  end

  it 'yields only tuples with the expected data' do
    expect { subject }.to change { yields.dup }.
      from([]).
      to([ [ 2 ] ])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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