Sha256: c8b381598b8d20a52ca21abb07cbd1c012ee940dd609e781038ef8451a0c7f09

Contents?: true

Size: 1.78 KB

Versions: 57

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe Picky::Index do

  context 'without stubbed categories' do
    before(:each) do
      @index = described_class.new :some_index_name
    end

    describe 'category' do
      it 'adds a new category to the categories' do
        @index.category :some_category_name

        @index.categories.categories.size.should == 1
      end
      it 'returns the new category' do
        @index.category(:some_category_name).should be_kind_of(Picky::Category)
      end
    end
  end

  context "with stubbed categories" do
    before(:each) do
      @categories = stub :categories

      @index = described_class.new :some_name
      @index.category :some_category_name1
      @index.category :some_category_name2

      @index.stub! :categories => @categories
    end

    describe "load" do
      it "delegates to each category" do
        @categories.should_receive(:load).once.with

        @index.load
      end
    end
    describe "possible_combinations" do
      it "delegates to the combinator" do
        @categories.should_receive(:possible_combinations).once.with :some_token

        @index.possible_combinations :some_token
      end
    end
  end

  context 'result_identifier' do
    context 'with it set' do
      let(:index) do
        described_class.new :some_name do
          result_identifier :some_identifier
        end
      end
      it 'has an after_indexing set' do
        index.result_identifier.should == :some_identifier
      end
    end
    context 'with it not set' do
      let(:index) do
        described_class.new :some_name do
        end
      end
      it 'returns the name' do
        index.result_identifier.should == :some_name
      end
    end
  end

  context "no categories" do
    it "works" do
      described_class.new :some_name
    end
  end

end

Version data entries

57 entries across 57 versions & 1 rubygems

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