Sha256: ff920fb18c3a086e9b7b6d547d6ea2f726ea2b10734a6dc7fa4c703cdbcd6ea7

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe IndexBundle do
  
  let(:some_index) { stub :index, :name => :some_index, :internal_indexed => :indexed_index, :internal_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 :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

2 entries across 2 versions & 1 rubygems

Version Path
picky-2.5.2 spec/lib/index_bundle_spec.rb
picky-2.5.1 spec/lib/index_bundle_spec.rb