Sha256: f79d5cd1f50c1a4e4e5b9b8756ff4ceb2b98346cd54d3287aa3f26d9a3dd17cf

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Binary::UnoptimizedOperands, '#optimizable?' do
  subject { object.optimizable? }

  let(:attribute)       { Attribute::Integer.new(:id)                                                         }
  let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary }                        }
  let(:function)        { Class.new(Veritas::Function) { include Veritas::Function::Binary }.new(left, right) }
  let(:object)          { described_class.new(function)                                                       }

  before do
    described_class.class_eval { include Optimizer::Function::Binary::UnoptimizedOperands }
  end

  context 'when left is optimizable' do
    let(:left)  { attribute.include([ 1 ]) }
    let(:right) { attribute.ne(2)          }

    it { should be(true) }
  end

  context 'when right is optimizable' do
    let(:left)  { attribute.eq(1)          }
    let(:right) { attribute.exclude([ 2 ]) }

    it { should be(true) }
  end

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

    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/function/binary/unoptimized_operands/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimizable_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimizable_spec.rb