Sha256: d3ee982540b111aa2b39fca5111a15f074c7d734a70133448b96a59a1e258742

Contents?: true

Size: 1.5 KB

Versions: 57

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe Picky::Indexes do

  context 'after initialize' do
    let(:indexes) { described_class.new }
    it 'has no indexes' do
      indexes.indexes.should == []
    end
  end

  describe 'methods' do
    let(:indexes) { described_class.new }
    before(:each) do
      @index1 = stub :index1, :name => :index1
      @index2 = stub :index2, :name => :index2
      indexes.register @index1
      indexes.register @index2
    end
    describe 'index' do
      it 'prepares and caches each' do
        scheduler = stub :scheduler, :fork? => false, :finish => nil

        @index1.should_receive(:prepare).once.with(scheduler).ordered
        @index2.should_receive(:prepare).once.with(scheduler).ordered

        @index1.should_receive(:cache).once.with(scheduler).ordered
        @index2.should_receive(:cache).once.with(scheduler).ordered

        indexes.index scheduler
      end
    end
    describe 'register' do
      it 'should have indexes' do
        indexes.indexes.should == [@index1, @index2]
      end
    end
    describe 'clear_indexes' do
      it 'clears the indexes' do
        indexes.clear_indexes

        indexes.indexes.should == []
      end
    end
    def self.it_delegates_each name
      describe name do
        it "calls #{name} on each in order" do
          @index1.should_receive(name).once.with.ordered
          @index2.should_receive(name).once.with.ordered

          indexes.send name
        end
      end
    end
    it_delegates_each :clear
  end

end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
picky-4.12.1 spec/lib/indexes_indexing_spec.rb
picky-4.12.0 spec/lib/indexes_indexing_spec.rb
picky-4.11.3 spec/lib/indexes_indexing_spec.rb
picky-4.11.2 spec/lib/indexes_indexing_spec.rb
picky-4.11.1 spec/lib/indexes_indexing_spec.rb
picky-4.11.0 spec/lib/indexes_indexing_spec.rb
picky-4.10.0 spec/lib/indexes_indexing_spec.rb
picky-4.9.0 spec/lib/indexes_indexing_spec.rb
picky-4.8.1 spec/lib/indexes_indexing_spec.rb
picky-4.8.0 spec/lib/indexes_indexing_spec.rb
picky-4.7.0 spec/lib/indexes_indexing_spec.rb
picky-4.6.6 spec/lib/indexes_indexing_spec.rb
picky-4.6.5 spec/lib/indexes_indexing_spec.rb
picky-4.6.4 spec/lib/indexes_indexing_spec.rb
picky-4.6.3 spec/lib/indexes_indexing_spec.rb
picky-4.6.2 spec/lib/indexes_indexing_spec.rb
picky-4.6.1 spec/lib/indexes_indexing_spec.rb
picky-4.6.0 spec/lib/indexes_indexing_spec.rb
picky-4.5.12 spec/lib/indexes_indexing_spec.rb
picky-4.5.11 spec/lib/indexes_indexing_spec.rb