Sha256: 064b7ac996dfe052febf2ec1c3c9a46263ba23ea15b76a04cf15d45bb75d8c8b

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Predicate::Enumerable::UnoptimizedOperands, '#optimizable?' do
  subject { object.optimizable? }

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

  before do
    predicate.should be_kind_of(Function::Predicate::Enumerable)
  end

  context 'when the operand contains an unsorted Enumerable' do
    let(:operand) { [ 2, 1 ] }

    it { should be(true) }
  end

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

    it { should be(true) }
  end

  context 'when the operand contains an Enumerable after filtering invalid entries' do
    let(:operand) { [ 'a', 1, 2 ] }

    it { should be(true) }
  end

  context 'when the operand contains an Enumerable after filtering duplicate entries' do
    let(:operand) { [ 1, 1, 2, 2 ] }

    it { should be(true) }
  end

  context 'when the operand contains a sorted Enumerable' do
    let(:operand) { [ 1, 2 ] }

    it { should be(false) }
  end

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

    it { should be(false) }
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
axiom-optimizer-0.1.0 spec/unit/axiom/optimizer/function/predicate/enumerable/unoptimized_operands/optimizable_predicate_spec.rb
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/function/predicate/enumerable/unoptimized_operands/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/function/predicate/enumerable/unoptimized_operands/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/function/predicate/enumerable/unoptimized_operands/optimizable_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/function/predicate/enumerable/unoptimized_operands/optimizable_spec.rb