Sha256: 488c5b10bd1fd468c25c6b6b70af75515d4414240f18088f1fe30375d1f24fd2

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:header) { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ])                }
  let(:left)   { Relation.new(header.project([ :id   ]), [ [ 1 ], [ 2 ] ])                    }
  let(:right)  { Relation.new(header.project([ :name ]), [ [ 'Dan Kubb' ], [ 'Alex Kubb' ] ]) }
  let(:object) { described_class.new(left, right)                                             }
  let(:yields) { []                                                                           }

  it_should_behave_like 'an #each method'

  it 'yields each tuple' do
    expect { subject }.to change { yields.dup }.
      from([]).
      to([ [ 1, 'Dan Kubb' ], [ 1, 'Alex Kubb' ], [ 2, 'Dan Kubb' ], [ 2, 'Alex Kubb' ] ])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-0.0.7 spec/unit/veritas/algebra/product/each_spec.rb
veritas-0.0.6 spec/unit/veritas/algebra/product/each_spec.rb
veritas-0.0.5 spec/unit/veritas/algebra/product/each_spec.rb
veritas-0.0.4 spec/unit/veritas/algebra/product/each_spec.rb