/
indexes_indexing_spec.rb
60 lines (51 loc) · 1.5 KB
/
indexes_indexing_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# encoding: utf-8
#
require 'spec_helper'
describe Picky::Indexes do
context 'after initialize' do
let(:indexes) { described_class.new }
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 'index' do
it 'prepares and caches each' do
scheduler = stub :scheduler, :fork? => false, :finish => nil
@index1.should_receive(:prepare).once.with(scheduler).ordered
@index2.should_receive(:prepare).once.with(scheduler).ordered
@index1.should_receive(:cache).once.with(scheduler).ordered
@index2.should_receive(:cache).once.with(scheduler).ordered
indexes.index scheduler
end
end
describe 'register' do
it 'should have indexes' do
indexes.indexes.should == [@index1, @index2]
end
end
describe 'clear_indexes' do
it 'clears the indexes' do
indexes.clear_indexes
indexes.indexes.should == []
end
end
def self.it_delegates_each name
describe name do
it "calls #{name} on each in order" do
@index1.should_receive(name).once.with.ordered
@index2.should_receive(name).once.with.ordered
indexes.send name
end
end
end
it_delegates_each :clear
end
end