Sha256: 9567d06b45b369f6c164312fea5145e1d9da7bb925a44bdedb67b821d6d38b48

Contents?: true

Size: 1.41 KB

Versions: 30

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe Picky::Indexers::Base do

  let(:some_index_or_category) { double :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 'forwards it to the index or category' do
      some_index_or_category.should_receive(:source).once.with no_args

      indexer.source
    end
    it 'raises when none is there' do
      some_index_or_category.should_receive(:source).at_least(1).and_return nil

      indexer.stub :process

      expect {
        indexer.prepare Picky::Categories.new
      }.to raise_error("Trying to index without a source for some_index_or_category.")
    end
  end

  describe 'prepare' do
    before(:each) do
      some_index_or_category.should_receive(:source).at_least(1).and_return :some_source
    end
    it 'processes' do
      categories = double :categories, :empty => nil, :cache => nil

      indexer.should_receive(:process).once.with :some_source, categories, anything

      indexer.prepare categories
    end
    it 'calls the right methods on the categories' do
      indexer.stub :process

      categories = double :categories

      categories.should_receive(:empty).once.ordered

      indexer.prepare categories
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
picky-4.31.3 spec/lib/indexers/base_spec.rb
picky-4.31.2 spec/lib/indexers/base_spec.rb
picky-4.31.1 spec/lib/indexers/base_spec.rb
picky-4.31.0 spec/lib/indexers/base_spec.rb
picky-4.30.0 spec/lib/indexers/base_spec.rb
picky-4.29.0 spec/lib/indexers/base_spec.rb
picky-4.28.1 spec/lib/indexers/base_spec.rb
picky-4.27.1 spec/lib/indexers/base_spec.rb
picky-4.27.0 spec/lib/indexers/base_spec.rb
picky-4.26.2 spec/lib/indexers/base_spec.rb
picky-4.26.1 spec/lib/indexers/base_spec.rb
picky-4.26.0 spec/lib/indexers/base_spec.rb
picky-4.25.3 spec/lib/indexers/base_spec.rb
picky-4.25.2 spec/lib/indexers/base_spec.rb
picky-4.25.1 spec/lib/indexers/base_spec.rb
picky-4.25.0 spec/lib/indexers/base_spec.rb
picky-4.24.0 spec/lib/indexers/base_spec.rb
picky-4.23.2 spec/lib/indexers/base_spec.rb
picky-4.23.1 spec/lib/indexers/base_spec.rb
picky-4.23.0 spec/lib/indexers/base_spec.rb