Sha256: 688f70df44ca8c11bb2ce87d853d4945914657a343539e285518479087ec6bbe

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Indexers::Base do

  let(:some_index_or_category) { stub :some_index_or_category, :name => 'some index or category' }
  let(:indexer) { described_class.new some_index_or_category }
  
  describe 'index_or_category' do
    it 'returns the right thing' do
      indexer.index_or_category.should == some_index_or_category
    end
  end
  
  describe 'source' do
    it 'delegates it to the index or category' do
      some_index_or_category.should_receive(:source).once.with
      
      indexer.source
    end
  end
  
  describe 'index' do
    it 'messages, then processed' do
      indexer.should_receive(:start_indexing_message).once.with.ordered
      indexer.should_receive(:prepare).once.with(:categories).ordered
      indexer.should_receive(:process).once.with(:categories).ordered
      indexer.should_receive(:finish_indexing_message).once.with.ordered
      
      indexer.index :categories
    end
  end
  
  describe 'prepare' do
    it 'calls a certain method on each category' do
      some_index_or_category.stub! :source
      
      category1 = stub :category1
      category2 = stub :category2
      category3 = stub :category3
      
      categories = [category1, category2, category3]
      
      categories.each do |category|
        category.should_receive(:prepare_index_directory).once.with
      end
      
      indexer.prepare categories
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.7.0 spec/lib/indexers/base_spec.rb