Sha256: bffc20b0c23d634f4c8d06aa20aa78ce81853dbe8ca92cc7e1e49fa4e0a9ff3e

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

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

      subject{ op.keys }

      context 'when keys are not split by the group' do
        let(:operand){
          an_operand.with_heading(:id => Integer, :name => String).
                     with_keys([ :id ])
        }

        context 'when a key is not part of the group' do
          let(:op){ 
            a_lispy.group(operand, [:name], :names)
          }

          it { should eq(Keys[ [:id] ]) }
        end

        context 'when a key is not part of the group and --allbut' do
          let(:op){ 
            a_lispy.group(operand, [:id], :names, :allbut => true)
          }

          it { should eq(Keys[ [:id] ]) }
        end

        context 'when a whole key is part of the group' do
          let(:op){ 
            a_lispy.group(operand, [:id], :ids)
          }

          it { should eq(Keys[ [:ids] ]) }
        end

        context 'when a whole key is part of the group and --allbut' do
          let(:op){ 
            a_lispy.group(operand, [:name], :ids, :allbut => true)
          }

          it { should eq(Keys[ [:ids] ]) }
        end
      end

      context 'when keys are split by the group' do
        let(:operand){
          an_operand.with_heading(:sid => Integer, :pid => Integer, :price => Float).
                     with_keys([ :sid, :pid ])
        }

        context '--no-allbut' do
          let(:op){
            a_lispy.group(operand, [:pid, :price], :parts)
          }

          it{ should eq(Keys[ [:sid] ]) }
        end

      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-algebra/operator/group/test_keys.rb
alf-core-0.14.0 spec/unit/alf-algebra/operator/group/test_keys.rb
alf-core-0.13.1 spec/unit/alf-algebra/operator/group/test_keys.rb
alf-core-0.13.0 spec/unit/alf-algebra/operator/group/test_keys.rb