Sha256: 28f4e96f01c01483b94939a078b7901f80c12e95fdf7e214683e37bb9556515e

Contents?: true

Size: 1.5 KB

Versions: 24

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe Indexed::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 = stub :index1, :name => :index1
      @index2 = stub :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.should == []
      end
      it 'clears the mapping' do
        indexes.clear
        
        indexes.index_mapping.should == {}
      end
    end
    describe 'reload' do
      it 'calls load_from_cache on each in order' do
        @index1.should_receive(:load_from_cache).once.with.ordered
        @index2.should_receive(:load_from_cache).once.with.ordered

        indexes.reload
      end
    end
  end
  
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
picky-2.5.2 spec/lib/indexed/indexes_spec.rb
picky-2.5.1 spec/lib/indexed/indexes_spec.rb
picky-2.5.0 spec/lib/indexed/indexes_spec.rb
picky-2.4.3 spec/lib/indexed/indexes_spec.rb
picky-2.4.2 spec/lib/indexed/indexes_spec.rb
picky-2.4.1 spec/lib/indexed/indexes_spec.rb
picky-2.4.0 spec/lib/indexed/indexes_spec.rb
picky-2.3.0 spec/lib/indexed/indexes_spec.rb
picky-2.2.1 spec/lib/indexed/indexes_spec.rb
picky-2.2.0 spec/lib/indexed/indexes_spec.rb
picky-2.1.2 spec/lib/indexed/indexes_spec.rb
picky-2.1.1 spec/lib/indexed/indexes_spec.rb
picky-2.1.0 spec/lib/indexed/indexes_spec.rb
picky-2.0.0 spec/lib/indexed/indexes_spec.rb
picky-2.0.0.pre3 spec/lib/indexed/indexes_spec.rb
picky-2.0.0.pre2 spec/lib/indexed/indexes_spec.rb
picky-2.0.0.pre1 spec/lib/indexed/indexes_spec.rb
picky-1.5.4 spec/lib/indexed/indexes_spec.rb
picky-1.5.3 spec/lib/indexed/indexes_spec.rb
picky-1.5.2 spec/lib/indexed/indexes_spec.rb