Sha256: cf02208c2b5b87cb8d582d5684d5bdf7175997d37940c42941e7f76df0852d47

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Rename::ReverseOperand, '#optimize' do
  subject { object.optimize }

  let(:base)     { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ].each) }
  let(:limit)    { base.sort_by { |r| r.id }.take(2)                  }
  let(:operand)  { limit.rename({}).reverse                           }
  let(:relation) { operand.rename(:id => :other_id)                   }
  let(:object)   { described_class.new(relation)                      }

  before do
    object.should be_optimizable
  end

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

  its(:operand) { should eql(limit.rename(:id => :other_id)) }

  its(:directions) { should == [ relation[:other_id].desc ] }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb