Sha256: 7cb50fae759c5e972032d6f14b699301ca7f6ac79e06e7ce010f4da1ba63b1c3

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

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

      subject{ op.type_check }

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

        it{ should eq(op.heading) }
      end

      context 'when not a grouped attribute' do
        let(:op){ 
          unwrap(suppliers, :sid)
        }

        it 'should raise an error' do
          lambda{
            subject
          }.should raise_error(TypeCheckError, /not a tuple-valued attribute `sid`/)
        end
      end

      context 'when name clash resulting' do
        let(:op){ 
          inside = wrap(suppliers, [:status, :city], :extra)
          inside = rename(inside, :sid => :city)
          unwrap(inside, :extra)
        }

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