picky 0.3.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/lib/picky/application.rb +2 -2
  2. data/lib/picky/cacher/partial/default.rb +1 -1
  3. data/lib/picky/configuration/field.rb +8 -10
  4. data/lib/picky/configuration/indexes.rb +6 -6
  5. data/lib/picky/configuration/queries.rb +4 -3
  6. data/lib/picky/cores.rb +2 -2
  7. data/lib/picky/extensions/array.rb +2 -12
  8. data/lib/picky/generator.rb +27 -4
  9. data/lib/picky/index/bundle.rb +5 -41
  10. data/lib/picky/index/bundle_checker.rb +58 -0
  11. data/lib/picky/index/type.rb +4 -1
  12. data/lib/picky/index/wrappers/exact_first.rb +57 -0
  13. data/lib/picky/indexes.rb +12 -19
  14. data/lib/picky/loader.rb +7 -8
  15. data/lib/picky/query/allocation.rb +1 -1
  16. data/lib/picky/query/combinations.rb +9 -6
  17. data/lib/picky/query/combinator.rb +11 -5
  18. data/lib/picky/rack/harakiri.rb +1 -1
  19. data/lib/picky/results/base.rb +4 -12
  20. data/lib/picky/results/live.rb +0 -6
  21. data/lib/picky/routing.rb +17 -17
  22. data/lib/picky/sources/csv.rb +1 -2
  23. data/lib/picky/sources/db.rb +0 -1
  24. data/lib/picky/sources/delicious.rb +41 -0
  25. data/lib/picky/tokenizers/base.rb +52 -43
  26. data/lib/picky/tokenizers/default/index.rb +7 -0
  27. data/lib/picky/tokenizers/default/query.rb +7 -0
  28. data/lib/picky/tokenizers/index.rb +0 -9
  29. data/lib/picky/tokenizers/query.rb +0 -9
  30. data/lib/tasks/application.rake +1 -1
  31. data/lib/tasks/cache.rake +41 -48
  32. data/lib/tasks/framework.rake +1 -1
  33. data/lib/tasks/index.rake +22 -12
  34. data/lib/tasks/server.rake +3 -3
  35. data/lib/tasks/shortcuts.rake +9 -2
  36. data/lib/tasks/statistics.rake +8 -8
  37. data/lib/tasks/try.rake +4 -2
  38. data/project_prototype/Gemfile +1 -1
  39. data/project_prototype/app/application.rb +7 -3
  40. data/spec/lib/cacher/partial/default_spec.rb +1 -1
  41. data/spec/lib/cacher/partial/none_spec.rb +12 -0
  42. data/spec/lib/cacher/partial/subtoken_spec.rb +29 -1
  43. data/spec/lib/configuration/field_spec.rb +162 -3
  44. data/spec/lib/configuration/indexes_spec.rb +150 -0
  45. data/spec/lib/cores_spec.rb +43 -0
  46. data/spec/lib/extensions/module_spec.rb +27 -16
  47. data/spec/lib/generator_spec.rb +3 -3
  48. data/spec/lib/index/bundle_checker_spec.rb +67 -0
  49. data/spec/lib/index/bundle_spec.rb +0 -50
  50. data/spec/lib/index/type_spec.rb +47 -0
  51. data/spec/lib/index/wrappers/exact_first_spec.rb +95 -0
  52. data/spec/lib/indexers/base_spec.rb +18 -2
  53. data/spec/lib/loader_spec.rb +21 -1
  54. data/spec/lib/query/allocation_spec.rb +25 -0
  55. data/spec/lib/query/base_spec.rb +37 -0
  56. data/spec/lib/query/combination_spec.rb +10 -1
  57. data/spec/lib/query/combinations_spec.rb +82 -3
  58. data/spec/lib/query/combinator_spec.rb +45 -0
  59. data/spec/lib/query/token_spec.rb +24 -0
  60. data/spec/lib/rack/harakiri_spec.rb +28 -0
  61. data/spec/lib/results/base_spec.rb +24 -0
  62. data/spec/lib/results/live_spec.rb +15 -0
  63. data/spec/lib/routing_spec.rb +5 -0
  64. data/spec/lib/sources/db_spec.rb +31 -1
  65. data/spec/lib/sources/delicious_spec.rb +75 -0
  66. data/spec/lib/tokenizers/base_spec.rb +160 -49
  67. data/spec/lib/tokenizers/default/index_spec.rb +11 -0
  68. data/spec/lib/tokenizers/default/query_spec.rb +11 -0
  69. metadata +26 -5
  70. data/lib/picky/index/combined.rb +0 -45
  71. data/lib/picky/tokenizers/default.rb +0 -3
@@ -1,10 +1,169 @@
1
1
  require 'spec_helper'
2
- describe "Configuration::Field" do
2
+ describe Configuration::Field do
3
3
 
4
4
  context "unit specs" do
5
+ describe "virtual?" do
6
+ context "with virtual true" do
7
+ before(:each) do
8
+ @field = Configuration::Field.new :some_name, :some_tokenizer, :virtual => true
9
+ end
10
+ it "returns the right value" do
11
+ @field.virtual?.should == true
12
+ end
13
+ end
14
+ context "with virtual object" do
15
+ before(:each) do
16
+ @field = Configuration::Field.new :some_name, :some_tokenizer, :virtual => 123.6
17
+ end
18
+ it "returns the right value" do
19
+ @field.virtual?.should == true
20
+ end
21
+ end
22
+ context "with virtual nil" do
23
+ before(:each) do
24
+ @field = Configuration::Field.new :some_name, :virtual => nil
25
+ end
26
+ it "returns the right value" do
27
+ @field.virtual?.should == false
28
+ end
29
+ end
30
+ context "with virtual false" do
31
+ before(:each) do
32
+ @field = Configuration::Field.new :some_name, :virtual => false
33
+ end
34
+ it "returns the right value" do
35
+ @field.virtual?.should == false
36
+ end
37
+ end
38
+ end
39
+ describe "tokenizer" do
40
+ context "with specific tokenizer" do
41
+ before(:each) do
42
+ @field = Configuration::Field.new :some_name, Tokenizers::Index.new
43
+
44
+ @field.type = :some_type
45
+ end
46
+ it "caches" do
47
+ @field.tokenizer.should == @field.tokenizer
48
+ end
49
+ it "returns an instance" do
50
+ @field.tokenizer.should be_kind_of(Tokenizers::Index)
51
+ end
52
+ end
53
+ end
54
+ describe "indexer" do
55
+ context "with default indexer" do
56
+ before(:each) do
57
+ @field = Configuration::Field.new :some_name, :some_tokenizer
58
+ end
59
+ it "caches" do
60
+ @field.indexer.should == @field.indexer
61
+ end
62
+ end
63
+ context "with specific indexer" do
64
+ before(:each) do
65
+ @field = Configuration::Field.new :some_name, :indexer => Indexers::Default
66
+
67
+ @field.type = :some_type
68
+ end
69
+ it "caches" do
70
+ @field.indexer.should == @field.indexer
71
+ end
72
+ it "returns an instance" do
73
+ @field.indexer.should be_kind_of(Indexers::Default)
74
+ end
75
+ it "creates a new instance of the right class" do
76
+ Indexers::Default.should_receive(:new).once.with :some_type, @field
77
+
78
+ @field.indexer
79
+ end
80
+ end
81
+ end
82
+ describe "cache" do
83
+ before(:each) do
84
+ @field = Configuration::Field.new :some_name, :some_tokenizer
85
+ @field.stub! :prepare_cache_directory
86
+
87
+ @generated = stub :generated, :generate_caches => nil
88
+ @field.stub! :generate => @generated
89
+ end
90
+ it "prepares the cache directory" do
91
+ @field.should_receive(:prepare_cache_directory).once.with
92
+
93
+ @field.cache
94
+ end
95
+ it "tells the indexer to index" do
96
+ @generated.should_receive(:generate_caches).once.with
97
+
98
+ @field.cache
99
+ end
100
+ end
101
+ describe "prepare_cache_directory" do
102
+ before(:each) do
103
+ @field = Configuration::Field.new :some_name, :some_tokenizer
104
+
105
+ @field.stub! :cache_directory => :some_cache_directory
106
+ end
107
+ it "tells the FileUtils to mkdir_p" do
108
+ FileUtils.should_receive(:mkdir_p).once.with :some_cache_directory
109
+
110
+ @field.prepare_cache_directory
111
+ end
112
+ end
113
+ describe "index" do
114
+ before(:each) do
115
+ @field = Configuration::Field.new :some_name, :some_tokenizer
116
+ @field.stub! :prepare_cache_directory
117
+
118
+ @indexer = stub :indexer, :index => nil
119
+ @field.stub! :indexer => @indexer
120
+ end
121
+ it "prepares the cache directory" do
122
+ @field.should_receive(:prepare_cache_directory).once.with
123
+
124
+ @field.index
125
+ end
126
+ it "tells the indexer to index" do
127
+ @indexer.should_receive(:index).once.with
128
+
129
+ @field.index
130
+ end
131
+ end
132
+ describe "source" do
133
+ context "with source" do
134
+ before(:each) do
135
+ @field = Configuration::Field.new :some_name, :some_tokenizer, :source => :some_given_source
136
+
137
+ @type = stub :type, :name => :some_type
138
+ @field.type = @type
139
+ end
140
+ it "returns the given source" do
141
+ @field.source.should == :some_given_source
142
+ end
143
+ end
144
+ context "without source" do
145
+ before(:each) do
146
+ @field = Configuration::Field.new :some_name, :some_tokenizer
147
+
148
+ @type = stub :type, :name => :some_type, :source => :some_type_source
149
+ @field.type = @type
150
+ end
151
+ it "returns the type's source" do
152
+ @field.source.should == :some_type_source
153
+ end
154
+ end
155
+ end
5
156
  context "name symbol" do
6
157
  before(:each) do
7
- @field = Configuration::Field.new :some_name
158
+ @field = Configuration::Field.new :some_name, :some_tokenizer
159
+
160
+ @type = stub :type, :name => :some_type
161
+ @field.type = @type
162
+ end
163
+ describe "search_index_file_name" do
164
+ it "returns the right file name" do
165
+ @field.search_index_file_name.should == 'some/search/root/index/test/some_type/prepared_some_name_index.txt'
166
+ end
8
167
  end
9
168
  describe "generate_qualifiers_from" do
10
169
  context "with qualifiers" do
@@ -30,7 +189,7 @@ describe "Configuration::Field" do
30
189
  end
31
190
  context "name string" do
32
191
  before(:each) do
33
- @field = Configuration::Field.new 'some_name'
192
+ @field = Configuration::Field.new 'some_name', :some_tokenizer
34
193
  end
35
194
  describe "generate_qualifiers_from" do
36
195
  context "without qualifiers" do
@@ -0,0 +1,150 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Configuration::Indexes do
5
+
6
+ before(:each) do
7
+ @config = Configuration::Indexes.new
8
+ end
9
+
10
+ describe "types" do
11
+ it "exists" do
12
+ lambda { @config.types }.should_not raise_error
13
+ end
14
+ it "is initially empty" do
15
+ @config.types.should be_empty
16
+ end
17
+ end
18
+
19
+ describe "default_tokenizer" do
20
+ it "is a default tokenizer" do
21
+ @config.default_tokenizer.should == Tokenizers::Default::Index
22
+ end
23
+ it "caches" do
24
+ @config.default_tokenizer.should == @config.default_tokenizer
25
+ end
26
+ end
27
+
28
+ describe "delegates" do
29
+ before(:each) do
30
+ @receiver = mock :receiver
31
+ @config.stub! :default_tokenizer => @receiver
32
+ end
33
+ it "delegates" do
34
+ @receiver.should_receive(:removes_characters).once
35
+
36
+ @config.removes_characters
37
+ end
38
+ it "delegates" do
39
+ @receiver.should_receive(:contracts_expressions).once
40
+
41
+ @config.contracts_expressions
42
+ end
43
+ it "delegates" do
44
+ @receiver.should_receive(:stopwords).once
45
+
46
+ @config.stopwords
47
+ end
48
+ it "delegates" do
49
+ @receiver.should_receive(:splits_text_on).once
50
+
51
+ @config.splits_text_on
52
+ end
53
+ it "delegates" do
54
+ @receiver.should_receive(:normalizes_words).once
55
+
56
+ @config.normalizes_words
57
+ end
58
+ it "delegates" do
59
+ @receiver.should_receive(:removes_characters_after_splitting).once
60
+
61
+ @config.removes_characters_after_splitting
62
+ end
63
+ end
64
+
65
+ describe "take_snapshot" do
66
+ before(:each) do
67
+ @type1 = stub :type, :name => :type1
68
+ @type2 = stub :type, :name => :type2
69
+
70
+ @config.stub! :types => [@type1, @type2]
71
+ end
72
+ it "tells type to make a snapshot" do
73
+ @type2.should_receive(:take_snapshot).once.with
74
+
75
+ @config.take_snapshot :type2
76
+ end
77
+ end
78
+ describe "index" do
79
+ before(:each) do
80
+ @type1 = stub :type, :name => :type1
81
+ @type2 = stub :type, :name => :type2
82
+
83
+ @config.stub! :types => [@type1, @type2]
84
+ end
85
+ it "tells type to index" do
86
+ @type2.should_receive(:index).once.with
87
+
88
+ @config.index :type2
89
+ end
90
+ end
91
+ describe "index_solr" do
92
+ before(:each) do
93
+ @type1 = stub :type, :name => :type1
94
+ @type2 = stub :type, :name => :type2
95
+
96
+ @config.stub! :types => [@type1, @type2]
97
+ end
98
+ it "tells type to index_solr" do
99
+ @type2.should_receive(:index_solr).once.with
100
+
101
+ @config.index_solr :type2
102
+ end
103
+ end
104
+
105
+ describe "only_if_included_in" do
106
+ before(:each) do
107
+ type1 = stub :type, :name => :type1
108
+ type2 = stub :type, :name => :type2
109
+
110
+ @config.stub! :types => [type1, type2]
111
+ end
112
+ context "without type names" do
113
+ it "calls the block" do
114
+ checker = stub :checker
115
+ checker.should_receive(:bla).twice
116
+
117
+ @config.only_if_included_in do |type|
118
+ checker.bla
119
+ end
120
+ end
121
+ it "calls the block" do
122
+ checker = stub :checker
123
+ checker.should_receive(:bla).twice
124
+
125
+ @config.only_if_included_in [] do |type|
126
+ checker.bla
127
+ end
128
+ end
129
+ end
130
+ context "with type names" do
131
+ it "is included" do
132
+ checker = stub :checker
133
+ checker.should_receive(:bla).once
134
+
135
+ @config.only_if_included_in [:type2, :type3, :type4] do |type|
136
+ checker.bla
137
+ end
138
+ end
139
+ it "is not included" do
140
+ checker = stub :checker
141
+ checker.should_receive(:bla).never
142
+
143
+ @config.only_if_included_in [:type3, :type4, :type5] do |type|
144
+ checker.bla
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ end
@@ -3,6 +3,49 @@ require 'spec_helper'
3
3
 
4
4
  describe Cores do
5
5
 
6
+ describe ".forked" do
7
+ before(:each) do
8
+ Process.should_receive(:fork).any_number_of_times.and_yield
9
+ end
10
+ context "with array" do
11
+ context "with block" do
12
+ it "runs ok" do
13
+ Cores.forked([1, 2]) do |e|
14
+
15
+ end
16
+ end
17
+ it "yields the elements" do
18
+ result = []
19
+ Cores.forked([1, 2]) do |e|
20
+ result << e
21
+ end
22
+ result.should == [1, 2]
23
+ end
24
+ end
25
+ context "without block" do
26
+ it "fails" do
27
+ lambda {
28
+ Cores.forked [1, 2]
29
+ }.should raise_error(LocalJumpError)
30
+ end
31
+ end
32
+ end
33
+ context "with empty array" do
34
+ context "with block" do
35
+ it "runs ok" do
36
+ Cores.forked([]) do
37
+
38
+ end
39
+ end
40
+ end
41
+ context "without block" do
42
+ it "runs ok" do
43
+ Cores.forked []
44
+ end
45
+ end
46
+ end
47
+ end
48
+
6
49
  describe 'number_of_cores' do
7
50
  before(:each) do
8
51
  @linux = mock :linux, :null_object => true
@@ -3,25 +3,36 @@ require 'spec_helper'
3
3
  describe Module do
4
4
 
5
5
  describe 'each_delegate' do
6
- before(:each) do
7
- @klass = Class.new do
8
-
9
- each_delegate :bli, :bla, :blu, :to => :@some_enumerable
10
-
11
- def initialize some_enumerable
12
- @some_enumerable = some_enumerable
6
+ context "with correct params" do
7
+ before(:each) do
8
+ @klass = Class.new do
9
+
10
+ each_delegate :bli, :bla, :blu, :to => :@some_enumerable
11
+
12
+ def initialize some_enumerable
13
+ @some_enumerable = some_enumerable
14
+ end
15
+
13
16
  end
14
-
17
+ end
18
+ it 'should send each a bli' do
19
+ bli = stub :bli
20
+ delegating = @klass.new [bli, bli, bli, bli]
21
+
22
+ bli.should_receive(:bli).exactly(4).times
23
+
24
+ delegating.bli
15
25
  end
16
26
  end
17
- it 'should send each a bli' do
18
- bli = stub :bli
19
- delegating = @klass.new [bli, bli, bli, bli]
20
-
21
- bli.should_receive(:bli).exactly(4).times
22
-
23
- delegating.bli
27
+ context "without correct params" do
28
+ it 'should send each a bli' do
29
+ lambda do
30
+ Class.new do
31
+ each_delegate :bli, :bla, :blu # :to missing
32
+ end
33
+ end.should raise_error(ArgumentError)
34
+ end
24
35
  end
25
36
  end
26
-
37
+
27
38
  end
@@ -19,7 +19,7 @@ describe Picky::Generator do
19
19
  lambda { @generator.generator_for('project', 'some_project') }.should_not raise_error
20
20
  end
21
21
  it "should raise if a generator is not available" do
22
- lambda { @generator.generator_for('blarf', 'gnorf') }.should raise_error(Picky::NoGeneratorException)
22
+ lambda { @generator.generator_for('blarf', 'gnorf') }.should raise_error(Picky::NoGeneratorError)
23
23
  end
24
24
  it "should return a generator if it is available" do
25
25
  @generator.generator_for('project', 'some_project').should be_kind_of(Picky::Generator::Project)
@@ -27,8 +27,8 @@ describe Picky::Generator do
27
27
  end
28
28
 
29
29
  describe "generate" do
30
- it "should raise a NoGeneratorException if called with the wrong params" do
31
- lambda { @generator.generate(['blarf', 'gnorf']) }.should raise_error(Picky::NoGeneratorException)
30
+ it "should raise a NoGeneratorError if called with the wrong params" do
31
+ lambda { @generator.generate(['blarf', 'gnorf']) }.should raise_error(Picky::NoGeneratorError)
32
32
  end
33
33
  it "should not raise on the right params" do
34
34
  @generator.stub! :generator_for_class => stub(:generator, :generate => nil)
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Index::BundleChecker do
4
+
5
+ before(:each) do
6
+ @category = stub :category, :name => :some_category
7
+ @type = stub :type, :name => :some_type
8
+ @partial = stub :partial
9
+ @weights = stub :weights
10
+ @similarity = stub :similarity
11
+ @index_class = Index::Bundle
12
+ @index = @index_class.new :some_name, @category, @type, @partial, @weights, @similarity
13
+
14
+ @checker = @index.checker
15
+ end
16
+
17
+ describe 'raise_unless_cache_exists' do
18
+ before(:each) do
19
+ @checker.stub! :cache_small? => false
20
+ end
21
+ context 'weights cache missing' do
22
+ before(:each) do
23
+ @checker.stub! :cache_ok? => true
24
+ @index.stub! :weights_cache_path => 'weights_cache_path'
25
+ @checker.should_receive(:cache_ok?).any_number_of_times.with('weights_cache_path').and_return false
26
+ end
27
+ it 'should raise' do
28
+ lambda do
29
+ @checker.raise_unless_cache_exists
30
+ end.should raise_error("weights cache for some_name: some_type some_category missing.")
31
+ end
32
+ end
33
+ context 'similarity cache missing' do
34
+ before(:each) do
35
+ @checker.stub! :cache_ok? => true
36
+ @index.stub! :similarity_cache_path => 'similarity_cache_path'
37
+ @checker.should_receive(:cache_ok?).any_number_of_times.with('similarity_cache_path').and_return false
38
+ end
39
+ it 'should raise' do
40
+ lambda do
41
+ @checker.raise_unless_cache_exists
42
+ end.should raise_error("similarity cache for some_name: some_type some_category missing.")
43
+ end
44
+ end
45
+ context 'index cache missing' do
46
+ before(:each) do
47
+ @checker.stub! :cache_ok? => true
48
+ @index.stub! :index_cache_path => 'index_cache_path'
49
+ @checker.should_receive(:cache_ok?).any_number_of_times.with('index_cache_path').and_return false
50
+ end
51
+ it 'should raise' do
52
+ lambda do
53
+ @checker.raise_unless_cache_exists
54
+ end.should raise_error("index cache for some_name: some_type some_category missing.")
55
+ end
56
+ end
57
+ context 'all ok' do
58
+ before(:each) do
59
+ @checker.stub! :cache_ok? => true
60
+ end
61
+ it 'should not raise' do
62
+ lambda { @checker.raise_unless_cache_exists }.should_not raise_error
63
+ end
64
+ end
65
+ end
66
+
67
+ end
@@ -128,56 +128,6 @@ describe Index::Bundle do
128
128
  end
129
129
  end
130
130
 
131
- describe 'raise_unless_cache_exists' do
132
- before(:each) do
133
- @index.stub! :cache_small? => false
134
- end
135
- context 'weights cache missing' do
136
- before(:each) do
137
- @index.stub! :cache_ok? => true
138
- @index.stub! :weights_cache_path => 'weights_cache_path'
139
- @index.should_receive(:cache_ok?).any_number_of_times.with('weights_cache_path').and_return false
140
- end
141
- it 'should raise' do
142
- lambda do
143
- @index.raise_unless_cache_exists
144
- end.should raise_error("weights cache for some_name: some_type some_category missing.")
145
- end
146
- end
147
- context 'similarity cache missing' do
148
- before(:each) do
149
- @index.stub! :cache_ok? => true
150
- @index.stub! :similarity_cache_path => 'similarity_cache_path'
151
- @index.should_receive(:cache_ok?).any_number_of_times.with('similarity_cache_path').and_return false
152
- end
153
- it 'should raise' do
154
- lambda do
155
- @index.raise_unless_cache_exists
156
- end.should raise_error("similarity cache for some_name: some_type some_category missing.")
157
- end
158
- end
159
- context 'index cache missing' do
160
- before(:each) do
161
- @index.stub! :cache_ok? => true
162
- @index.stub! :index_cache_path => 'index_cache_path'
163
- @index.should_receive(:cache_ok?).any_number_of_times.with('index_cache_path').and_return false
164
- end
165
- it 'should raise' do
166
- lambda do
167
- @index.raise_unless_cache_exists
168
- end.should raise_error("index cache for some_name: some_type some_category missing.")
169
- end
170
- end
171
- context 'all ok' do
172
- before(:each) do
173
- @index.stub! :cache_ok? => true
174
- end
175
- it 'should not raise' do
176
- lambda { @index.raise_unless_cache_exists }.should_not raise_error
177
- end
178
- end
179
- end
180
-
181
131
  describe 'delete_all' do
182
132
  it 'should call delete with all paths' do
183
133
  @index.should_receive(:delete).once.with @index.index_cache_path
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Index::Type do
4
+
5
+ context "with categories" do
6
+ before(:each) do
7
+ @category1 = Index::Category.new :some_category_name1, :some_type1
8
+ @category2 = Index::Category.new :some_category_name2, :some_type2
9
+
10
+ @index = Index::Type.new :some_name, :some_result_type, false, @category1, @category2
11
+ end
12
+ describe "generate_caches" do
13
+ it "delegates to each category" do
14
+ @category1.should_receive(:generate_caches).once.with
15
+ @category2.should_receive(:generate_caches).once.with
16
+
17
+ @index.generate_caches
18
+ end
19
+ end
20
+ describe "load_from_cache" do
21
+ it "delegates to each category" do
22
+ @category1.should_receive(:load_from_cache).once.with
23
+ @category2.should_receive(:load_from_cache).once.with
24
+
25
+ @index.load_from_cache
26
+ end
27
+ end
28
+ end
29
+
30
+ context "no categories" do
31
+ before(:each) do
32
+ @combinator = stub :combinator
33
+ Query::Combinator.stub! :new => @combinator
34
+
35
+ @index = Index::Type.new :some_name, :some_result_type, false
36
+ end
37
+
38
+ describe "possible_combinations" do
39
+ it "delegates to the combinator" do
40
+ @combinator.should_receive(:possible_combinations_for).once.with :some_token
41
+
42
+ @index.possible_combinations :some_token
43
+ end
44
+ end
45
+ end
46
+
47
+ end