Sha256: 72f9753f411806a26e1ce1917c546a541d9e5d065b935f74cfb420dcd90c9b03

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Restriction::RestrictionOperand, '#optimizable?' do
  subject { object.optimizable? }

  let(:header)    { Relation::Header.coerce([[:id, Integer]])       }
  let(:base)      { Relation.new(header, LazyEnumerable.new([[1]])) }
  let(:predicate) { header[:id].eq(1)                               }
  let(:relation)  { operand.restrict { predicate }                  }
  let(:object)    { described_class.new(relation)                   }

  before do
    expect(object.operation).to be_kind_of(Algebra::Restriction)
  end

  context 'when the operand is an restriction operation' do
    let(:other_predicate) { header[:id].include([1])          }
    let(:operand)         { base.restrict { other_predicate } }

    it { should be(true) }
  end

  context 'when the operand is not a restriction operation' do
    let(:operand) { base }

    it { should be(false) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 spec/unit/axiom/optimizer/algebra/restriction/restriction_operand/optimizable_predicate_spec.rb
axiom-optimizer-0.1.1 spec/unit/axiom/optimizer/algebra/restriction/restriction_operand/optimizable_predicate_spec.rb