Sha256: 849e07e49a424bfcf443959be2227fd1a28ba87fea59247eefd51b2e62c45ac0

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Product, '.new' do
  subject { object.new(left, right) }

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

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

    it { should be_instance_of(object) }
  end

  context 'with relations having headers with common attributes' do
    let(:right) { Relation.new([ [ :id, Integer ], [ :name, String ] ], [ [ 2, 'Dan Kubb' ] ]) }

    specify { expect { subject }.to raise_error(InvalidHeaderError, 'the headers must be disjointed') }
  end

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

    specify { expect { subject }.to raise_error(InvalidHeaderError, 'the headers must be disjointed') }
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/algebra/product/class_methods/new_spec.rb
veritas-0.0.7 spec/unit/veritas/algebra/product/class_methods/new_spec.rb
veritas-0.0.6 spec/unit/veritas/algebra/product/class_methods/new_spec.rb
veritas-0.0.5 spec/unit/veritas/algebra/product/class_methods/new_spec.rb