Sha256: 3a31c887fe77db82ec1759ab2939685ff71c2dc66643ffb9100684b928310149

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Rename::OffsetOperand, '#optimizable?' do
  subject { object.optimizable? }

  let(:base)     { Relation.new([[:id, Integer]], LazyEnumerable.new([[1]])) }
  let(:aliases)  { { id: :other_id }                                         }
  let(:relation) { operand.rename(aliases)                                   }
  let(:object)   { described_class.new(relation)                             }

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

  context 'when the operand is an offset operation' do
    let(:operand) { base.sort_by { |r| r.id }.drop(1) }

    it { should be(true) }
  end

  context 'when the operand is not an offset 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/rename/offset_operand/optimizable_predicate_spec.rb
axiom-optimizer-0.1.1 spec/unit/axiom/optimizer/algebra/rename/offset_operand/optimizable_predicate_spec.rb