Sha256: 7a01b9a2c1b94ee60a82ceeac1f33fc09219dd1d1952ff437b85bf3c303cbeef

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Connective::Disjunction::OptimizableToInclusion, '#optimize' do
  subject { object.optimize }

  let(:attribute)  { Attribute::Integer.new(:id)     }
  let(:connective) { left.or(right)                  }
  let(:object)     { described_class.new(connective) }

  before do
    object.should be_optimizable
  end

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

    it { should be_kind_of(Function::Predicate::Inclusion) }

    its(:left) { should equal(attribute) }

    # enumerable order is normalized
    its(:right) { should == [ 1, 2 ] }
  end

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

    it { should be_kind_of(Function::Predicate::Inclusion) }

    its(:left) { should equal(attribute) }

    its(:right) { should == [ 1, 2 ] }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/function/connective/disjunction/optimizable_to_inclusion/optimize_spec.rb