Sha256: 1e8d095617669f9852804ceb7a995b1e7d164eee47091d7d028048f1133efbd0

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

require 'spec_helper'

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

  let(:klass)  { Algebra::Product                                                             }
  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) { klass.new(left, right)                                                       }
  let(:yields) { []                                                                           }

  it_should_behave_like 'a command 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

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/algebra/product/each_spec.rb