Sha256: eafd81ae838fdf99712c63d1c4dbe00c5509df4e876d4a90e44a49a8eb13b8a4

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Relation, '#optimize' do
  subject { object.optimize(*args) }

  let(:object) { described_class.new([ [ :id, Integer ] ], [ [ 1 ] ].each) }

  before do
    object.should be_instance_of(described_class)
  end

  context 'with no optimizer' do
    let(:args) { [] }

    it 'calls self.class.optimizer' do
      described_class.should_receive(:optimizer).and_return(nil)
      subject
    end

    it { should equal(object) }

    it_should_behave_like 'an optimize method'
  end

  context 'with an optimizer' do
    let(:optimized) { described_class.new([ [ :id, Integer ] ], [ [ 1 ] ].each) }
    let(:args)      { [ lambda { |relation| optimized } ]                       }

    it { should equal(optimized) }

    it_should_behave_like 'an optimize method'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/integration/veritas/relation/optimize_spec.rb
veritas-optimizer-0.0.6 spec/integration/veritas/relation/optimize_spec.rb
veritas-optimizer-0.0.5 spec/integration/veritas/relation/optimize_spec.rb
veritas-optimizer-0.0.4 spec/integration/veritas/relation/optimize_spec.rb