Sha256: a4fb6e1a795226f9181bf72058a6e528ff3989e4fcd24ad3588439340e411218

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Logic::Predicate::Comparable::NormalizableOperands#optimizable?' do
  subject { object.optimizable? }

  let(:klass)     { Optimizer::Logic::Predicate::Comparable::NormalizableOperands }
  let(:attribute) { Attribute::Integer.new(:id)                                   }
  let(:predicate) { Logic::Predicate::Equality.new(left, right)                   }
  let(:object)    { klass.new(predicate)                                          }

  before do
    predicate.should be_kind_of(Logic::Predicate::Comparable)
  end

  context 'when left and right is a constant' do
    let(:left)  { 1 }
    let(:right) { 1 }

    it { should be(false) }
  end

  context 'when left and right is an attribute' do
    let(:left)  { attribute }
    let(:right) { attribute }

    it { should be(false) }
  end

  context 'when left is a constant and right is an attribute' do
    let(:left)  { 1         }
    let(:right) { attribute }

    it { should be(true) }
  end

  context 'when left is an attribute and right is a constant' do
    let(:left)  { attribute }
    let(:right) { 1        }

    it { should be(false) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/logic/predicate/comparable/normalizable_operands/optimizable_spec.rb