Sha256: 33a5abfab158870d3b8cec45794b986d946190376f0db96a6c210f56fe058589

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

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

  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_not change { yields.dup }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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