Sha256: 9d95dbfd1beae4cadf6a3fdb9ddc7dfd46be44eb636d6b91893095922302cfc1

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'type_check_helper'
module Alf
  module Algebra
    describe Join, 'type_check' do

      subject{ op.type_check }

      context 'when ok' do
        let(:op){ 
          join(suppliers, suppliers)
        }

        it{ should eq(op.heading) }
      end

      context 'when nothing in common' do
        let(:right){
          an_operand.with_heading(foo: Integer)
        }
        let(:left){
          an_operand.with_heading(bar: String)
        }
        let(:op){ 
          join(left, right)
        }

        it{ should eq(op.heading) }
      end

      context 'when heading mismatch' do
        let(:right){
          an_operand.with_heading(sid: Integer)
        }
        let(:left){
          an_operand.with_heading(sid: String)
        }
        let(:op){ 
          join(left, right)
        }

        context 'when strict' do
          subject{ op.type_check(strict: true) }

          it 'should raise an error' do
            lambda{
              subject
            }.should raise_error(TypeCheckError, /heading mismatch/)
          end
        end

        context 'when not strict' do
          subject{ op.type_check }

          it 'should not raise an error' do
            subject.should eq(op.heading)
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-algebra/operator/join/test_type_check.rb