Sha256: fb1b775b29cfd8b45441cc173f35fffe1fbd50841390bd0b2a15b2cb862f4a07

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:attribute) { Attribute::Integer.new(:id)    }
  let(:predicate) { attribute.exclude(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::Tautology.instance) }
  end

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

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

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

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

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

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

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

    it { should equal(Function::Proposition::Tautology.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/exclusion/empty_right_operand/optimize_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/function/predicate/exclusion/empty_right_operand/optimize_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/function/predicate/exclusion/empty_right_operand/optimize_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/function/predicate/exclusion/empty_right_operand/optimize_spec.rb