Sha256: 9c1b0b63f84510f3e21d91d518d274b3d42939d8e1ea79b42adf1ca5ff9a2705

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

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

  before do
    expect(object).to be_optimizable
  end

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

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

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

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

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

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 spec/unit/axiom/optimizer/function/predicate/exclusion/empty_right/optimize_spec.rb
axiom-optimizer-0.1.1 spec/unit/axiom/optimizer/function/predicate/exclusion/empty_right/optimize_spec.rb