Sha256: 61db2a1b28534362d9445c4a07585a0169048d5b4846f87833b0a52e0f99b44f

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

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

      subject{ op.type_check }

      context 'when ok' do
        let(:op){ 
          quota(supplies, [:sid], [[:sid, :asc]], :sum => sum{ qty })
        }

        it{ should eq(op.heading) }
      end

      context 'when unknown by' do
        let(:op){ 
          quota(supplies, [:foo], [[:sid, :asc]], :sum => sum{ qty })
        }

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

      context 'when invalid ordering' do
        let(:op){ 
          quota(supplies, [:sid], [[:bar, :asc]], :sum => sum{ qty })
        }

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

      context 'when name clash' do
        let(:op){ 
          quota(supplies, [:sid], [[:sid, :asc]], :qty => sum{ qty })
        }

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