Sha256: ef945b1b6d793637b87e089d467e68d22cda43f1dec0aecfc059ebcdb3d9af77

Contents?: true

Size: 1.9 KB

Versions: 28

Compression:

Stored size: 1.9 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 'define_category' do
      it 'adds a new category to the categories' do
        @index.define_category :some_category_name
        
        @index.categories.categories.size.should == 1 
      end
      it 'returns the new category' do
        @index.define_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.define_category :some_category_name1
      @index.define_category :some_category_name2
      
      @index.stub! :categories => @categories
    end
    
    describe "load_from_cache" do
      it "delegates to each category" do
        @categories.should_receive(:load_from_cache).once.with
        
        @index.load_from_cache
      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

28 entries across 28 versions & 1 rubygems

Version Path
picky-3.5.4 spec/lib/index_indexed_spec.rb
picky-3.5.3 spec/lib/index_indexed_spec.rb
picky-3.5.2 spec/lib/index_indexed_spec.rb
picky-3.5.1 spec/lib/index_indexed_spec.rb
picky-3.5.0 spec/lib/index_indexed_spec.rb
picky-3.4.3 spec/lib/index_indexed_spec.rb
picky-3.4.2 spec/lib/index_indexed_spec.rb
picky-3.4.1 spec/lib/index_indexed_spec.rb
picky-3.4.0 spec/lib/index_indexed_spec.rb
picky-3.3.3 spec/lib/index_indexed_spec.rb
picky-3.3.2 spec/lib/index_indexed_spec.rb
picky-3.3.1 spec/lib/index_indexed_spec.rb
picky-3.3.0 spec/lib/index_indexed_spec.rb
picky-3.2.0 spec/lib/index_indexed_spec.rb
picky-3.1.13 spec/lib/index_indexed_spec.rb
picky-3.1.12 spec/lib/index_indexed_spec.rb
picky-3.1.11 spec/lib/index_indexed_spec.rb
picky-3.1.10 spec/lib/index_indexed_spec.rb
picky-3.1.9 spec/lib/index_indexed_spec.rb
picky-3.1.8 spec/lib/index_indexed_spec.rb