Sha256: cc9639410b9e95f9bf2be66fc50340268bfb89e5905778ee342df34aff7b89c6

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

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

      subject{ op.type_check }

      context 'when ok' do
        let(:op){ 
          not_matching(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){ 
          not_matching(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){ 
          not_matching(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/not_matching/test_type_check.rb