Sha256: df4b4364fe716ddaae5a46be2a2276e814f4cb1cf12947de3d9fdf7ed22c5fb6

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Logic::Connective::Conjunction::OptimizableToExclusion#optimize' do
  subject { object.optimize }

  let(:klass)      { Optimizer::Logic::Connective::Conjunction::OptimizableToExclusion }
  let(:attribute)  { Attribute::Integer.new(:id)                                       }
  let(:connective) { left.and(right)                                                   }
  let(:object)     { klass.new(connective)                                             }

  before do
    object.operation.should be_kind_of(Logic::Connective::Conjunction)
  end

  context 'when the right operands are optimizable' do
    let(:left)  { attribute.ne(2) }
    let(:right) { attribute.ne(1) }

    it 'reorders the operands by optimizing the exclusion' do
      should eql(attribute.exclude([ 1, 2 ]))
    end
  end

  context 'when the right operands are not optimizable' do
    let(:left)  { attribute.ne(1) }
    let(:right) { attribute.ne(2) }

    it { should eql(attribute.exclude([ 1, 2 ])) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.1 spec/unit/veritas/optimizer/logic/connective/conjunction/optimizable_to_exclusion/optimize_spec.rb