Sha256: 1d8f00008403fb55049c27f0012a252bc632d09729014b4f55bb09a61a367d99

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Predicate::Inclusion::EmptyRightOperand, '#optimize' do
  subject { object.optimize }

  let(:attribute) { Attribute::Integer.new(:id)    }
  let(:predicate) { attribute.include(operand)     }
  let(:object)    { described_class.new(predicate) }

  before do
    object.should be_optimizable
  end

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

    it { should equal(Function::Proposition::Contradiction.instance) }
  end

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

    it { should equal(Function::Proposition::Contradiction.instance) }
  end

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

    it { should equal(Function::Proposition::Contradiction.instance) }
  end

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

    it { should equal(Function::Proposition::Contradiction.instance) }
  end

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

    it { should equal(Function::Proposition::Contradiction.instance) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/function/predicate/inclusion/empty_right_operand/optimize_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/function/predicate/inclusion/empty_right_operand/optimize_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/function/predicate/inclusion/empty_right_operand/optimize_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/function/predicate/inclusion/empty_right_operand/optimize_spec.rb