Sha256: ba5a4eca5c424c7af7e34520497eaa00b53b53f469506ffd140cb98a80731d07

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Logic::Predicate::Exclusion::OneRightOperand#optimize' do
  subject { object.optimize }

  let(:klass)     { Optimizer::Logic::Predicate::Exclusion::OneRightOperand }
  let(:attribute) { Attribute::Integer.new(:id)                             }
  let(:predicate) { attribute.exclude(operand)                              }
  let(:object)    { klass.new(predicate)                                    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/logic/predicate/exclusion/one_right_operand/optimize_spec.rb