Sha256: 9fe4c4ac1ae49babb8efd0ee5652fb2f6ee3021932838b913bfd5c04b94e392c

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

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

      subject{ op.type_check }

      context 'when ok' do
        let(:op){ 
          wrap(suppliers, [:status, :city], :extra)
        }

        it{ should eq(op.heading) }
      end

      context 'when ok (allowed overriding)' do
        let(:op){ 
          wrap(suppliers, [:status, :city], :status)
        }

        it{ should eq(op.heading) }
      end

      context 'when no such attributes' do
        let(:op){ 
          wrap(suppliers, [:status, :foo, :bar], :extra)
        }

        it 'should raise an error' do
          lambda{
            subject
          }.should raise_error(TypeCheckError, /no such attributes `foo`,`bar`/)
        end
      end

      context 'when diasllowed overriding' do
        let(:op){ 
          wrap(suppliers, [:status, :city], :name)
        }

        it 'should raise an error' do
          lambda{
            subject
          }.should raise_error(TypeCheckError, /cannot override `name`/)
        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/wrap/test_type_check.rb