Sha256: a32ee1923749c6e5c43d3a224b1b9b92e35264b7ed029e3c6423ac4416a193b6

Contents?: true

Size: 976 Bytes

Versions: 3

Compression:

Stored size: 976 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Relation::Operation::Limit::LimitOperand, '#optimize' do
  subject { object.optimize }

  let(:order)  { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ].each).sort_by { |r| r.id } }
  let(:limit)  { order.take(2)                                                           }
  let(:object) { described_class.new(relation)                                           }

  before do
    object.should be_optimizable
  end

  context 'when the operand has a larger limit than the operation' do
    let(:relation) { limit.take(1) }

    it { should be_kind_of(Relation::Operation::Limit) }

    its(:operand) { should equal(order) }

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

  context 'when the operand has a smaller limit than the operation' do
    let(:relation) { limit.take(3) }

    it { should be_kind_of(Relation::Operation::Limit) }

    its(:operand) { should equal(order) }

    its(:limit) { should == 2 }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb