Sha256: 7d54d33938ee1d60bf118d1fc3d623821f835e24b98d25e27c4422fc8fafe40a

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Logic::Predicate::Enumerable::UnoptimizedOperand#optimize' do
  subject { object.optimize }

  let(:klass)     { Optimizer::Logic::Predicate::Enumerable::UnoptimizedOperand }
  let(:attribute) { Attribute::Integer.new(:id)                                 }
  let(:predicate) { attribute.include(operand)                                  }
  let(:object)    { klass.new(predicate)                                        }

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

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

    it { should be_kind_of(Logic::Predicate::Inclusion) }

    its(:left) { should equal(attribute) }

    its(:right) { should == [ 1, 2 ] }
  end

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

    it { should be_kind_of(Logic::Predicate::Inclusion) }

    its(:left) { should equal(attribute) }

    its(:right) { should == (1..2) }
  end

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

    it { should be_kind_of(Logic::Predicate::Inclusion) }

    its(:left) { should equal(attribute) }

    its(:right) { should == [ 1, 2 ] }
  end

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

    it { should be_kind_of(Logic::Predicate::Inclusion) }

    its(:left) { should equal(attribute) }

    its(:right) { should == [ 1, 2 ] }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/logic/predicate/enumerable/unoptimized_operand/optimize_spec.rb