Sha256: c169f3be43d13cd11e75ef1710ea66a02ef89245205e1ea5c7e8c47bf5ba93d4

Contents?: true

Size: 1.85 KB

Versions: 14

Compression:

Stored size: 1.85 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe IndexBundle do
  
  let(:some_index) { stub :index, :name => :some_index, :indexed => :indexed_index, :indexing => :indexing_index }
  let(:indexes) { described_class.new }
  let(:indexed) { stub :indexed, :register => nil }
  let(:indexing) { stub :indexing, :register => nil }
  
  before(:each) do
    indexes.stub! :indexing => indexing
    indexes.stub! :indexed  => indexed
  end
  
  def self.it_delegates method, receiver
    it "delegates #{method} to #{receiver}" do
      indexes.send(receiver).should_receive(method.to_sym).once
      
      indexes.send method
    end
  end
  
  describe 'delegation' do
    it_delegates :reload, :indexed
    it_delegates :load_from_cache, :indexed
    
    it_delegates :check_caches, :indexing
    it_delegates :find, :indexing
    it_delegates :generate_cache_only, :indexing
    it_delegates :generate_index_only, :indexing
    it_delegates :index, :indexing
    it_delegates :index_for_tests, :indexing
  end
  
  describe '[]' do
    before(:each) do
      indexes.register some_index
    end
    it 'takes strings' do
      indexes['some_index'].should == some_index
    end
    it 'takes symbols' do
      indexes[:some_index].should == some_index
    end
  end
  
  describe 'register' do
    it 'registers with the indexes' do
      indexes.register some_index
      
      indexes.indexes.should == [some_index]
    end
    it 'registers with the index map' do
      indexes.register some_index
      
      indexes[some_index.name].should == some_index
    end
    it 'registers with the indexing' do
      indexing.should_receive(:register).once.with :indexing_index
      
      indexes.register some_index
    end
    it 'registers with the indexed' do
      indexed.should_receive(:register).once.with :indexed_index
      
      indexes.register some_index
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
picky-2.1.2 spec/lib/index_bundle_spec.rb
picky-2.1.1 spec/lib/index_bundle_spec.rb
picky-2.1.0 spec/lib/index_bundle_spec.rb
picky-2.0.0 spec/lib/index_bundle_spec.rb
picky-2.0.0.pre3 spec/lib/index_bundle_spec.rb
picky-2.0.0.pre2 spec/lib/index_bundle_spec.rb
picky-2.0.0.pre1 spec/lib/index_bundle_spec.rb
picky-1.5.4 spec/lib/index_bundle_spec.rb
picky-1.5.3 spec/lib/index_bundle_spec.rb
picky-1.5.2 spec/lib/index_bundle_spec.rb
picky-1.5.1 spec/lib/index_bundle_spec.rb
picky-1.5.0 spec/lib/index_bundle_spec.rb
picky-1.4.3 spec/lib/index_bundle_spec.rb
picky-1.4.2 spec/lib/index_bundle_spec.rb