Sha256: 2fefad30900dd7cacaa454a5b3ba2ac335006c9665678c48e1b1dd36715fd24c

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Logic::Predicate::Exclusion::EmptyRightOperand#optimize' do
  subject { object.optimize }

  let(:klass)     { Optimizer::Logic::Predicate::Exclusion::EmptyRightOperand }
  let(:attribute) { Attribute::Integer.new(:id)                               }
  let(:predicate) { attribute.exclude(operand)                                }
  let(:object)    { klass.new(predicate)                                      }

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

  context 'when the operand contains a nil' do
    let(:operand) { nil }

    it { should equal(Logic::Proposition::True.instance) }
  end

  context 'when the operand contains an empty Enumerable' do
    let(:operand) { [] }

    it { should equal(Logic::Proposition::True.instance) }
  end

  context 'when the operand contains an empty inclusive Range' do
    let(:operand) { 1..0 }

    it { should equal(Logic::Proposition::True.instance) }
  end

  context 'when the operand contains an empty exclusive Range' do
    let(:operand) { 1...1 }

    it { should equal(Logic::Proposition::True.instance) }
  end

  context 'when the operand is empty after filtering invalid entries' do
    let(:operand) { [ 'a' ] }

    it { should equal(Logic::Proposition::True.instance) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/logic/predicate/exclusion/empty_right_operand/optimize_spec.rb