Sha256: 7edef1e9da5bc439dfe3c7b3ecec12341bbf9faab6f9cfadabea48d2d3d1db0c

Contents?: true

Size: 903 Bytes

Versions: 4

Compression:

Stored size: 903 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:header) { [ [ :id, Integer ] ]             }
  let(:left)   { Relation.new(header, [ [ 1 ] ])  }
  let(:object) { described_class.new(left, right) }
  let(:yields) { []                               }

  context 'with relations having similar bodies' do
    let(:right) { left.dup }

    it_should_behave_like 'an #each method'

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

  context 'with relations having different bodies' do
    let(:right) { Relation.new(header, [ [ 2 ] ]) }

    it_should_behave_like 'an #each method'

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

Version data entries

4 entries across 4 versions & 1 rubygems

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