Sha256: bd17dbd771135f7e9a8868c0d9b67d1234af1071c8f0ca93f6741495eb63becf

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Logic::Predicate::Enumerable::OneRightOperand#optimizable?' do
  subject { object.optimizable? }

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

  before do
    klass.class_eval { include Optimizer::Logic::Predicate::Enumerable::OneRightOperand }

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

  context 'when the operand contains a one entry Enumerable' do
    let(:operand) { [ 1 ] }

    it { should be(true) }
  end

  context 'when the operand contains a one entry inclusive Range' do
    let(:operand) { 1..1 }

    it { should be(true) }
  end

  context 'when the operand contains a one entry exclusive Range' do
    let(:operand) { 1...2 }

    it { should be(true) }
  end

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

    it { should be(true) }
  end

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

    it { should be(true) }
  end

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

    it { should be(false) }
  end

  context 'when the operand contains a more than one entry inclusive Range' do
    let(:operand) { 1..2 }

    it { should be(false) }
  end

  context 'when the operand contains a more than one entry exclusive Range' do
    let(:operand) { 1...3 }

    it { should be(false) }
  end

  context 'when the operand contains more than one entry after filtering invalid entries' do
    let(:operand) { [ 'a', 1, 2 ] }

    it { should be(false) }
  end

  context 'when the operand contains more than one entry after filtering duplicate entries' do
    let(:operand) { [ 2, 1, 2, 1 ] }

    it { should be(false) }
  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/one_right_operand/optimizable_spec.rb