Sha256: 93a9381860b4c039cd67113f178d242f24a6095ea7c404cb593773fb3c35c22d

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Relation::Materialized, '#optimize' do
  subject { object.optimize }

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

  context 'with an empty Array' do
    let(:body) { [] }

    it { should eql(Relation::Empty.new(object.header)) }

    it 'returns an equivalent object to the unoptimized operation' do
      should == object
    end

    it 'does not execute body#each' do
      body.should_not_receive(:each)
      subject
    end

    it_should_behave_like 'an optimize method'
  end

  context 'with an nonempty Array' do
    let(:body) { [ [ 1 ] ] }

    it { should equal(object) }

    it 'does not execute body#each' do
      body.should_not_receive(:each)
      subject
    end

    it_should_behave_like 'an optimize method'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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