Sha256: 5148b2a00b66fa0afa4077dd5bed0a684889e7417688b16ce263c1a646304eef

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 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 = double :index1, :name => :index1
      @index2 = double :index2, :name => :index2
      indexes.register @index1
      indexes.register @index2
    end
    describe 'index' do
      it 'prepares and caches each' do
        scheduler = double :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_forwards_each name
      describe "forwarding ##{name}" do
        it "calls #{name} on each in order" do
          @index1.should_receive(name).once.with(no_args).ordered
          @index2.should_receive(name).once.with(no_args).ordered

          indexes.send name
        end
      end
    end
    it_forwards_each :clear
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
picky-4.31.3 spec/lib/indexes_indexing_spec.rb
picky-4.31.2 spec/lib/indexes_indexing_spec.rb
picky-4.31.1 spec/lib/indexes_indexing_spec.rb
picky-4.31.0 spec/lib/indexes_indexing_spec.rb
picky-4.30.0 spec/lib/indexes_indexing_spec.rb
picky-4.29.0 spec/lib/indexes_indexing_spec.rb
picky-4.28.1 spec/lib/indexes_indexing_spec.rb