Sha256: c588886e275621dc7a1826ebd3684c195a7e90716619d41a21093639fcc94ee9

Contents?: true

Size: 1.48 KB

Versions: 30

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Picky::Indexes do

  context 'after initialize' do
    let(:indexes) { described_class.new }
    it 'has an empty mapping' do
      indexes.index_mapping.should == {}
    end
    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 '[]' do
      it 'should use the mapping' do
        indexes[:index2].should == @index2
      end
      it 'should allow strings' do
        indexes['index1'].should == @index1
      end
    end
    describe 'register' do
      it 'should have indexes' do
        indexes.indexes.should == [@index1, @index2]
      end
      it 'should have a mapping' do
        indexes.index_mapping.should == { :index1 => @index1, :index2 => @index2 }
      end
    end
    describe 'clear' do
      it 'clears the indexes' do
        indexes.clear_indexes

        indexes.indexes.should == []
      end
      it 'clears the mapping' do
        indexes.clear_indexes

        indexes.index_mapping.should == {}
      end
    end
    describe 'load' do
      it 'calls load on each in order' do
        @index1.should_receive(:load).once.with(no_args).ordered
        @index2.should_receive(:load).once.with(no_args).ordered

        indexes.load
      end
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
picky-4.22.0 spec/lib/indexes_indexed_spec.rb
picky-4.21.2 spec/lib/indexes_indexed_spec.rb
picky-4.21.1 spec/lib/indexes_indexed_spec.rb
picky-4.21.0 spec/lib/indexes_indexed_spec.rb
picky-4.20.2 spec/lib/indexes_indexed_spec.rb
picky-4.20.1 spec/lib/indexes_indexed_spec.rb
picky-4.20.0 spec/lib/indexes_indexed_spec.rb
picky-4.19.7 spec/lib/indexes_indexed_spec.rb
picky-4.19.6 spec/lib/indexes_indexed_spec.rb
picky-4.19.5 spec/lib/indexes_indexed_spec.rb