Sha256: eef0ec6fcf105abfb18f6e67400127d5dc74e7f9553948c300974aa330d57555

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Extension::UnoptimizedOperand, '#optimizable?' do
  subject { object.optimizable? }

  let(:header)   { Relation::Header.new([ [ :id, Integer ] ]) }
  let(:base)     { Relation.new(header, [ [ 1 ] ].each)       }
  let(:relation) { operand.extend { |r| r.add(*extensions) }  }
  let(:object)   { described_class.new(relation)              }

  before do
    object.operation.should be_kind_of(Algebra::Extension)
  end

  context 'when the operand is optimizable' do
    let(:operand)    { base.rename({}) }
    let(:extensions) { [ :text, 1 ]    }

    it { should be(true) }
  end

  context 'when the extensions are optimizable' do
    let(:operand)    { base                                          }
    let(:extensions) { [ :text, Function::Numeric::Absolute.new(1) ] }

    it { should be(true) }
  end

  context 'when the operand and extensions are not optimizable' do
    let(:operand)    { base         }
    let(:extensions) { [ :text, 1 ] }

    it { should be(false) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb