Sha256: 53bf83132ffa8e7937935d9f2d78abcd3ef1223dc067cc839ee074c87a13cb00

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
module Alf
  module Algebra
    describe Allbut, 'keys' do

      let(:operand){
        an_operand.with_heading(id: Integer, name: String, status: String).
                   with_keys([:id], [:name])
      }

      subject{ op.keys }

      context 'when conserving at least one key' do
        let(:op){
          a_lispy.allbut(operand, [:name])
        }
        let(:expected){
          Keys[ [:id] ]
        }

        it { should eq(expected) }
      end

      context 'when projecting all keys away through --allbut' do
        let(:op){
          a_lispy.allbut(operand, [:id, :name])
        }
        let(:expected){
          Keys[ [:status] ]
        }

        it { should eq(expected) }
      end

      context 'when a key is projected due to a constant restriction' do
        let(:operand){
          an_operand.with_heading(sid: Integer, pid: Integer)
                    .with_keys([:sid, :pid])
        }
        let(:op){
          a_lispy.allbut(a_lispy.restrict(operand, sid: 1), [:sid])
        }
        let(:expected){
          Keys[ [:pid] ]
        }

        it { should eq(expected) }
      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/allbut/test_keys.rb