/
index_indexed_spec.rb
70 lines (58 loc) · 1.56 KB
/
index_indexed_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
61
62
63
64
65
66
67
68
69
70
require 'spec_helper'
describe Picky::Index do
context 'without stubbed categories' do
before(:each) do
@index = described_class.new :some_index_name
end
describe 'category' do
it 'adds a new category to the categories' do
@index.category :some_category_name
@index.categories.categories.size.should == 1
end
it 'returns the new category' do
@index.category(:some_category_name).should be_kind_of(Picky::Category)
end
end
end
context "with stubbed categories" do
before(:each) do
@categories = double :categories
@index = described_class.new :some_name
@index.category :some_category_name1
@index.category :some_category_name2
@index.stub :categories => @categories
end
describe "load" do
it "forwards to each category" do
@categories.should_receive(:load).once.with no_args
@index.load
end
end
end
context 'result_identifier' do
context 'with it set' do
let(:index) do
described_class.new :some_name do
result_identifier :some_identifier
end
end
it 'has an after_indexing set' do
index.result_identifier.should == :some_identifier
end
end
context 'with it not set' do
let(:index) do
described_class.new :some_name do
end
end
it 'returns the name' do
index.result_identifier.should == :some_name
end
end
end
context "no categories" do
it "works" do
described_class.new :some_name
end
end
end