picky 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/lib/picky/alias_instances.rb +1 -0
  2. data/lib/picky/application.rb +6 -7
  3. data/lib/picky/bundle.rb +31 -0
  4. data/lib/picky/configuration/indexes.rb +30 -41
  5. data/lib/picky/configuration/type.rb +6 -40
  6. data/lib/picky/ext/maybe_compile.rb +9 -0
  7. data/lib/picky/index/bundle.rb +1 -139
  8. data/lib/picky/{query/combinator.rb → index/categories.rb} +16 -18
  9. data/lib/picky/index/category.rb +20 -46
  10. data/lib/picky/index/type.rb +16 -12
  11. data/lib/picky/index/types.rb +41 -0
  12. data/lib/picky/index/wrappers/exact_first.rb +5 -1
  13. data/lib/picky/indexers/base.rb +9 -8
  14. data/lib/picky/indexing/bundle.rb +152 -0
  15. data/lib/picky/indexing/categories.rb +36 -0
  16. data/lib/picky/indexing/category.rb +145 -0
  17. data/lib/picky/indexing/type.rb +45 -0
  18. data/lib/picky/indexing/types.rb +74 -0
  19. data/lib/picky/loader.rb +17 -7
  20. data/lib/picky/query/base.rb +5 -4
  21. data/lib/picky/sources/wrappers/base.rb +23 -0
  22. data/lib/picky/sources/wrappers/location.rb +92 -0
  23. data/lib/picky/tokenizers/index.rb +4 -1
  24. data/lib/picky/type.rb +46 -0
  25. data/lib/picky/types.rb +38 -0
  26. data/lib/tasks/index.rake +4 -0
  27. data/project_prototype/Gemfile +1 -1
  28. data/project_prototype/app/application.rb +12 -12
  29. data/spec/lib/application_spec.rb +6 -9
  30. data/spec/lib/configuration/indexes_spec.rb +0 -85
  31. data/spec/lib/index/bundle_spec.rb +2 -94
  32. data/spec/lib/index/category_spec.rb +7 -86
  33. data/spec/lib/index/type_spec.rb +14 -26
  34. data/spec/lib/index/wrappers/exact_first_spec.rb +12 -12
  35. data/spec/lib/{index → indexing}/bundle_partial_generation_speed_spec.rb +2 -2
  36. data/spec/lib/indexing/bundle_spec.rb +174 -0
  37. data/spec/lib/{query/combinator_spec.rb → indexing/categories_spec.rb} +30 -34
  38. data/spec/lib/indexing/category_spec.rb +257 -0
  39. data/spec/lib/indexing/type_spec.rb +32 -0
  40. data/spec/lib/loader_spec.rb +0 -2
  41. data/spec/lib/query/base_spec.rb +8 -17
  42. data/spec/lib/query/full_spec.rb +3 -6
  43. data/spec/lib/query/live_spec.rb +4 -3
  44. data/spec/lib/sources/wrappers/base_spec.rb +35 -0
  45. data/spec/lib/sources/wrappers/location_spec.rb +68 -0
  46. data/spec/lib/tokenizers/index_spec.rb +2 -5
  47. metadata +32 -16
  48. data/lib/picky/configuration/field.rb +0 -73
  49. data/lib/picky/indexes.rb +0 -179
  50. data/lib/picky/initializers/ext.rb +0 -1
  51. data/spec/lib/configuration/field_spec.rb +0 -208
  52. data/spec/lib/configuration/type_spec.rb +0 -49
@@ -0,0 +1,174 @@
1
+ require 'spec_helper'
2
+
3
+ describe Indexing::Bundle 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 = Indexing::Bundle
12
+ @index = @index_class.new :some_name, @category, @type, @partial, @weights, @similarity
13
+ end
14
+
15
+ describe 'identifier' do
16
+ it 'should return a specific identifier' do
17
+ @index.identifier.should == 'some_name: some_type some_category'
18
+ end
19
+ end
20
+
21
+ describe 'initialize_index_for' do
22
+ context 'token not yet assigned' do
23
+ before(:each) do
24
+ @index.stub! :index => {}
25
+ end
26
+ it 'should assign it an empty array' do
27
+ @index.initialize_index_for :some_token
28
+
29
+ @index.index[:some_token].should == []
30
+ end
31
+ end
32
+ context 'token already assigned' do
33
+ before(:each) do
34
+ @index.stub! :index => { :some_token => :already_assigned }
35
+ end
36
+ it 'should not assign it anymore' do
37
+ @index.initialize_index_for :some_token
38
+
39
+ @index.index[:some_token].should == :already_assigned
40
+ end
41
+ end
42
+ end
43
+
44
+ # TODO
45
+ #
46
+ # describe 'retrieve' do
47
+ # it 'should call the other methods correctly' do
48
+ # results = stub :results
49
+ # @index.stub! :execute_query => results
50
+ # @index.should_receive(:extract).once.with results
51
+ #
52
+ # @index.retrieve
53
+ # end
54
+ # end
55
+
56
+ describe 'load_from_index_file' do
57
+ it 'should call two methods in order' do
58
+ @index.should_receive(:load_from_index_generation_message).once.ordered
59
+ @index.should_receive(:clear).once.ordered
60
+ @index.should_receive(:retrieve).once.ordered
61
+
62
+ @index.load_from_index_file
63
+ end
64
+ end
65
+
66
+ describe 'generate_derived' do
67
+ it 'should call two methods in order' do
68
+ @index.should_receive(:generate_weights).once.ordered
69
+ @index.should_receive(:generate_similarity).once.ordered
70
+
71
+ @index.generate_derived
72
+ end
73
+ end
74
+
75
+ describe 'generate_caches_from_memory' do
76
+ it 'should call two methods in order' do
77
+ @index.should_receive(:cache_from_memory_generation_message).once.ordered
78
+ @index.should_receive(:generate_derived).once.ordered
79
+
80
+ @index.generate_caches_from_memory
81
+ end
82
+ end
83
+
84
+ describe 'generate_caches_from_source' do
85
+ it 'should call two methods in order' do
86
+ @index.should_receive(:load_from_index_file).once.ordered
87
+ @index.should_receive(:generate_caches_from_memory).once.ordered
88
+
89
+ @index.generate_caches_from_source
90
+ end
91
+ end
92
+
93
+ describe 'dump' do
94
+ it 'should trigger dumps' do
95
+ @index.should_receive(:dump_index).once.with
96
+ @index.should_receive(:dump_similarity).once.with
97
+ @index.should_receive(:dump_weights).once.with
98
+
99
+ @index.dump
100
+ end
101
+ end
102
+
103
+ describe 'raise_unless_cache_exists' do
104
+ before(:each) do
105
+ @files = stub :files
106
+ @files.stub! :index_cache_ok? => true
107
+ @files.stub! :similarity_cache_ok? => true
108
+ @files.stub! :weights_cache_ok? => true
109
+ @files.stub! :index_cache_small? => false
110
+ @files.stub! :similarity_cache_small? => false
111
+ @files.stub! :weights_cache_small? => false
112
+
113
+ @index.stub! :files => @files
114
+ end
115
+ context 'weights cache missing' do
116
+ before(:each) do
117
+ @files.stub! :weights_cache_ok? => false
118
+ end
119
+ it 'should raise' do
120
+ lambda do
121
+ @index.raise_unless_cache_exists
122
+ end.should raise_error("weights cache for some_name: some_type some_category missing.")
123
+ end
124
+ end
125
+ context 'similarity cache missing' do
126
+ before(:each) do
127
+ @files.stub! :similarity_cache_ok? => false
128
+ end
129
+ it 'should raise' do
130
+ lambda do
131
+ @index.raise_unless_cache_exists
132
+ end.should raise_error("similarity cache for some_name: some_type some_category missing.")
133
+ end
134
+ end
135
+ context 'index cache missing' do
136
+ before(:each) do
137
+ @files.stub! :index_cache_ok? => false
138
+ end
139
+ it 'should raise' do
140
+ lambda do
141
+ @index.raise_unless_cache_exists
142
+ end.should raise_error("index cache for some_name: some_type some_category missing.")
143
+ end
144
+ end
145
+ end
146
+
147
+ describe 'initialization' do
148
+ before(:each) do
149
+ @category = stub :category, :name => :some_category
150
+ @type = stub :type, :name => :some_type
151
+
152
+ @index = @index_class.new :some_name, @category, @type, :similarity, :partial, :weights
153
+ end
154
+ it 'should initialize the index correctly' do
155
+ @index.index.should == {}
156
+ end
157
+ it 'should initialize the weights index correctly' do
158
+ @index.weights.should == {}
159
+ end
160
+ it 'should initialize the similarity index correctly' do
161
+ @index.similarity.should == {}
162
+ end
163
+ it 'should initialize the partial strategy correctly' do
164
+ @index.partial_strategy.should == :partial
165
+ end
166
+ it 'should initialize the weights strategy correctly' do
167
+ @index.weights_strategy.should == :weights
168
+ end
169
+ it 'should initialize the similarity strategy correctly' do
170
+ @index.similarity_strategy.should == :similarity
171
+ end
172
+ end
173
+
174
+ end
@@ -1,61 +1,57 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Query::Combinator do
3
+ describe Index::Categories do
4
4
 
5
5
  context 'with option ignore_unassigned_tokens' do
6
- before(:each) do
7
- @category1 = stub :category1, :name => :category1
8
- @category2 = stub :category2, :name => :category2
9
- @category3 = stub :category3, :name => :category3
10
- @categories = [@category1, @category2, @category3]
11
- end
12
6
  context 'ignore_unassigned_tokens true' do
13
7
  before(:each) do
14
- @combinator = Query::Combinator.new @categories, :ignore_unassigned_tokens => true
8
+ @categories = Index::Categories.new ignore_unassigned_tokens: true
15
9
  end
16
10
  it 'should return the right value' do
17
- @combinator.ignore_unassigned_tokens.should == true
11
+ @categories.ignore_unassigned_tokens.should == true
18
12
  end
19
13
  end
20
14
  context 'ignore_unassigned_tokens false' do
21
15
  before(:each) do
22
- @combinator = Query::Combinator.new @categories, :ignore_unassigned_tokens => false
16
+ @categories = Index::Categories.new ignore_unassigned_tokens: false
23
17
  end
24
18
  it 'should return the right value' do
25
- @combinator.ignore_unassigned_tokens.should == false
19
+ @categories.ignore_unassigned_tokens.should == false
26
20
  end
27
21
  end
28
22
  end
29
23
 
30
24
  context "with real categories" do
31
25
  before(:each) do
32
- @type1 = stub :type1, :name => :some_type
26
+ @type1 = stub :type1, :name => :some_type
33
27
 
34
- @category1 = Index::Category.new :some_name, @type1
35
- @category2 = Index::Category.new :some_name, @type1
36
- @category3 = Index::Category.new :some_name, @type1
37
- @categories = [@category1, @category2, @category3]
38
-
39
- @combinator = Query::Combinator.new @categories
28
+ @categories = Index::Categories.new
29
+ @categories << Index::Category.new(:category1, @type1)
30
+ @categories << Index::Category.new(:category2, @type1)
31
+ @categories << Index::Category.new(:category3, @type1)
40
32
  end
41
33
  describe "similar_possible_for" do
42
34
  before(:each) do
43
35
  @token = Query::Token.processed 'similar~'
44
36
  end
45
37
  it "returns possible categories" do
46
- @combinator.similar_possible_for(@token).should == []
38
+ @categories.similar_possible_for(@token).should == []
47
39
  end
48
40
  end
49
41
  end
50
42
 
51
43
  context 'without options' do
52
44
  before(:each) do
53
- @category1 = stub :category1, :name => :category1
54
- @category2 = stub :category2, :name => :category2
55
- @category3 = stub :category3, :name => :category3
56
- @categories = [@category1, @category2, @category3]
45
+ @type1 = stub :type1, :name => :some_type
46
+
47
+ @category1 = Index::Category.new :category1, @type1
48
+ @category2 = Index::Category.new :category2, @type1
49
+ @category3 = Index::Category.new :category3, @type1
57
50
 
58
- @combinator = Query::Combinator.new @categories
51
+ @categories = Index::Categories.new
52
+ @categories << @category1
53
+ @categories << @category2
54
+ @categories << @category3
59
55
  end
60
56
 
61
57
  describe "possible_combinations_for" do
@@ -67,9 +63,9 @@ describe Query::Combinator do
67
63
  @token.stub :similar? => true
68
64
  end
69
65
  it "calls the right method" do
70
- @combinator.should_receive(:similar_possible_for).once.with @token
66
+ @categories.should_receive(:similar_possible_for).once.with @token
71
67
 
72
- @combinator.possible_combinations_for @token
68
+ @categories.possible_combinations_for @token
73
69
  end
74
70
  end
75
71
  context "with non-similar token" do
@@ -77,9 +73,9 @@ describe Query::Combinator do
77
73
  @token.stub :similar? => false
78
74
  end
79
75
  it "calls the right method" do
80
- @combinator.should_receive(:possible_for).once.with @token
76
+ @categories.should_receive(:possible_for).once.with @token
81
77
 
82
- @combinator.possible_combinations_for @token
78
+ @categories.possible_combinations_for @token
83
79
  end
84
80
  end
85
81
  end
@@ -96,7 +92,7 @@ describe Query::Combinator do
96
92
  @category2.stub! :combination_for => @combination
97
93
  end
98
94
  it 'should return the right combinations' do
99
- @combinator.possible_for(@token).should == [@combination]
95
+ @categories.possible_for(@token).should == [@combination]
100
96
  end
101
97
  end
102
98
  context 'combination does not exist' do
@@ -104,7 +100,7 @@ describe Query::Combinator do
104
100
  @category2.stub! :combination_for => nil
105
101
  end
106
102
  it 'should return the right combinations' do
107
- @combinator.possible_for(@token).should == []
103
+ @categories.possible_for(@token).should == []
108
104
  end
109
105
  end
110
106
  end
@@ -123,7 +119,7 @@ describe Query::Combinator do
123
119
  @token = stub :token, :user_defined_category_name => :category2
124
120
  end
125
121
  it 'should return the right categories' do
126
- @combinator.possible_categories(@token).should == [@category2]
122
+ @categories.possible_categories(@token).should == [@category2]
127
123
  end
128
124
  end
129
125
  context 'user defined does not exist' do
@@ -131,7 +127,7 @@ describe Query::Combinator do
131
127
  @token = stub :token, :user_defined_category_name => nil
132
128
  end
133
129
  it 'should return all categories' do
134
- @combinator.possible_categories(@token).should == @categories
130
+ @categories.possible_categories(@token).should == [@category1, @category2, @category3]
135
131
  end
136
132
  end
137
133
  end
@@ -142,7 +138,7 @@ describe Query::Combinator do
142
138
  @token = stub :token, :user_defined_category_name => :category2
143
139
  end
144
140
  it 'should return the right categories' do
145
- @combinator.user_defined_categories(@token).should == [@category2]
141
+ @categories.user_defined_categories(@token).should == [@category2]
146
142
  end
147
143
  end
148
144
  context 'category does not exist' do
@@ -150,7 +146,7 @@ describe Query::Combinator do
150
146
  @token = stub :token, :user_defined_category_name => :gnoergel
151
147
  end
152
148
  it 'should return nil' do
153
- @combinator.user_defined_categories(@token).should == nil
149
+ @categories.user_defined_categories(@token).should == nil
154
150
  end
155
151
  end
156
152
  end
@@ -0,0 +1,257 @@
1
+ require 'spec_helper'
2
+ describe Indexing::Category do
3
+
4
+ context "unit specs" do
5
+ before(:each) do
6
+ @type = stub :some_type, :name => :some_type
7
+ @category = Indexing::Category.new :some_name, @type
8
+ @exact = @category.exact
9
+ @partial = @category.partial
10
+ end
11
+ describe 'dump_caches' do
12
+ before(:each) do
13
+ @exact.stub! :dump
14
+ @partial.stub! :dump
15
+ end
16
+ it 'should dump the exact index' do
17
+ @exact.should_receive(:dump).once.with
18
+
19
+ @category.dump_caches
20
+ end
21
+ it 'should dump the partial index' do
22
+ @partial.should_receive(:dump).once.with
23
+
24
+ @category.dump_caches
25
+ end
26
+ end
27
+
28
+ describe 'generate_derived_partial' do
29
+ it 'should delegate to partial' do
30
+ @partial.should_receive(:generate_derived).once.with
31
+
32
+ @category.generate_derived_partial
33
+ end
34
+ end
35
+
36
+ describe 'generate_derived_exact' do
37
+ it 'should delegate to exact' do
38
+ @exact.should_receive(:generate_derived).once.with
39
+
40
+ @category.generate_derived_exact
41
+ end
42
+ end
43
+
44
+ describe 'generate_indexes_from_exact_index' do
45
+ it 'should call three method in order' do
46
+ @category.should_receive(:generate_derived_exact).once.with().ordered
47
+ @category.should_receive(:generate_partial).once.with().ordered
48
+ @category.should_receive(:generate_derived_partial).once.with().ordered
49
+
50
+ @category.generate_indexes_from_exact_index
51
+ end
52
+ end
53
+
54
+ describe 'generate_caches_from_memory' do
55
+ it 'should delegate to partial' do
56
+ @partial.should_receive(:generate_caches_from_memory).once.with
57
+
58
+ @category.generate_caches_from_memory
59
+ end
60
+ end
61
+
62
+ describe 'generate_partial' do
63
+ it 'should return whatever the partial generation returns' do
64
+ @exact.stub! :index
65
+ @partial.stub! :generate_partial_from => :generation_returns
66
+
67
+ @category.generate_partial
68
+ end
69
+ it 'should use the exact index to generate the partial index' do
70
+ exact_index = stub :exact_index
71
+ @exact.stub! :index => exact_index
72
+ @partial.should_receive(:generate_partial_from).once.with(exact_index)
73
+
74
+ @category.generate_partial
75
+ end
76
+ end
77
+
78
+ describe 'generate_caches_from_source' do
79
+ it 'should delegate to exact' do
80
+ @exact.should_receive(:generate_caches_from_source).once.with
81
+
82
+ @category.generate_caches_from_source
83
+ end
84
+ end
85
+
86
+ describe 'generate_caches' do
87
+ it 'should call multiple methods in order' do
88
+ @category.should_receive(:generate_caches_from_source).once.with().ordered
89
+ @category.should_receive(:generate_partial).once.with().ordered
90
+ @category.should_receive(:generate_caches_from_memory).once.with().ordered
91
+ @category.should_receive(:dump_caches).once.with().ordered
92
+ @category.should_receive(:timed_exclaim).once.ordered
93
+
94
+ @category.generate_caches
95
+ end
96
+ end
97
+
98
+ describe "virtual?" do
99
+ context "with virtual true" do
100
+ before(:each) do
101
+ @category = Indexing::Category.new :some_name, @type, virtual: true
102
+ end
103
+ it "returns the right value" do
104
+ @category.virtual?.should == true
105
+ end
106
+ end
107
+ context "with virtual object" do
108
+ before(:each) do
109
+ @category = Indexing::Category.new :some_name, @type, :virtual => 123.6
110
+ end
111
+ it "returns the right value" do
112
+ @category.virtual?.should == true
113
+ end
114
+ end
115
+ context "with virtual nil" do
116
+ before(:each) do
117
+ @category = Indexing::Category.new :some_name, @type, :virtual => nil
118
+ end
119
+ it "returns the right value" do
120
+ @category.virtual?.should == false
121
+ end
122
+ end
123
+ context "with virtual false" do
124
+ before(:each) do
125
+ @category = Indexing::Category.new :some_name, @type, :virtual => false
126
+ end
127
+ it "returns the right value" do
128
+ @category.virtual?.should == false
129
+ end
130
+ end
131
+ end
132
+ describe "tokenizer" do
133
+ context "with specific tokenizer" do
134
+ before(:each) do
135
+ @category = Indexing::Category.new :some_name, @type, tokenizer: Tokenizers::Index.new
136
+ end
137
+ it "caches" do
138
+ @category.tokenizer.should == @category.tokenizer
139
+ end
140
+ it "returns an instance" do
141
+ @category.tokenizer.should be_kind_of(Tokenizers::Index)
142
+ end
143
+ end
144
+ end
145
+ describe "indexer" do
146
+ context "with default indexer" do
147
+ before(:each) do
148
+ @category = Indexing::Category.new :some_name, @type
149
+ end
150
+ it "caches" do
151
+ @category.indexer.should == @category.indexer
152
+ end
153
+ end
154
+ context "with specific indexer" do
155
+ before(:each) do
156
+ @category = Indexing::Category.new :some_name, @type, tokenizer: Indexers::Default
157
+ end
158
+ it "caches" do
159
+ @category.indexer.should == @category.indexer
160
+ end
161
+ it "returns an instance" do
162
+ @category.indexer.should be_kind_of(Indexers::Default)
163
+ end
164
+ it "creates a new instance of the right class" do
165
+ Indexers::Default.should_receive(:new).once.with @type, @category
166
+
167
+ @category.indexer
168
+ end
169
+ end
170
+ end
171
+ describe "cache" do
172
+ before(:each) do
173
+ @category = Indexing::Category.new :some_name, @type
174
+ @category.stub! :prepare_cache_directory
175
+
176
+ @category.stub! :generate_caches
177
+ end
178
+ it "prepares the cache directory" do
179
+ @category.should_receive(:prepare_cache_directory).once.with
180
+
181
+ @category.cache
182
+ end
183
+ it "tells the indexer to index" do
184
+ @category.should_receive(:generate_caches).once.with
185
+
186
+ @category.cache
187
+ end
188
+ end
189
+ describe "prepare_cache_directory" do
190
+ before(:each) do
191
+ @category = Indexing::Category.new :some_name, @type
192
+
193
+ @category.stub! :cache_directory => :some_cache_directory
194
+ end
195
+ it "tells the FileUtils to mkdir_p" do
196
+ FileUtils.should_receive(:mkdir_p).once.with :some_cache_directory
197
+
198
+ @category.prepare_cache_directory
199
+ end
200
+ end
201
+ describe "index" do
202
+ before(:each) do
203
+ @category = Indexing::Category.new :some_name, @type
204
+ @category.stub! :prepare_cache_directory
205
+
206
+ @indexer = stub :indexer, :index => nil
207
+ @category.stub! :indexer => @indexer
208
+ end
209
+ it "prepares the cache directory" do
210
+ @category.should_receive(:prepare_cache_directory).once.with
211
+
212
+ @category.index
213
+ end
214
+ it "tells the indexer to index" do
215
+ @indexer.should_receive(:index).once.with
216
+
217
+ @category.index
218
+ end
219
+ end
220
+ describe "source" do
221
+ context "with source" do
222
+ before(:each) do
223
+ @category = Indexing::Category.new :some_name, @type, :source => :some_given_source
224
+ end
225
+ it "returns the given source" do
226
+ @category.source.should == :some_given_source
227
+ end
228
+ end
229
+ context "without source" do
230
+ before(:each) do
231
+ @type = stub :type, :name => :some_type, :source => :some_type_source
232
+
233
+ @category = Indexing::Category.new :some_name, @type
234
+ end
235
+ it "returns the type's source" do
236
+ @category.source.should == :some_type_source
237
+ end
238
+ end
239
+ end
240
+ context "name symbol" do
241
+ before(:each) do
242
+ @category = Indexing::Category.new :some_name, @type
243
+ end
244
+ describe "search_index_file_name" do
245
+ it "returns the right file name" do
246
+ @category.search_index_file_name.should == 'some/search/root/index/test/some_type/prepared_some_name_index.txt'
247
+ end
248
+ end
249
+ end
250
+ context "name string" do
251
+ it "works" do
252
+ @category = Indexing::Category.new 'some_name', @type
253
+ end
254
+ end
255
+ end
256
+
257
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Indexing::Type do
4
+
5
+ context "with categories" do
6
+ before(:each) do
7
+ @source = stub :some_source
8
+
9
+ @categories = stub :categories
10
+
11
+ @index = Indexing::Type.new :some_name, @source
12
+ @index.add_category :some_category_name1
13
+ @index.add_category :some_category_name2
14
+
15
+ @index.stub! :categories => @categories
16
+ end
17
+ describe "generate_caches" do
18
+ it "delegates to each category" do
19
+ @categories.should_receive(:generate_caches).once.with
20
+
21
+ @index.generate_caches
22
+ end
23
+ end
24
+ end
25
+
26
+ context "no categories" do
27
+ it "works" do
28
+ Indexing::Type.new :some_name, @source
29
+ end
30
+ end
31
+
32
+ end
@@ -4,8 +4,6 @@ describe Loader do
4
4
 
5
5
  before(:each) do
6
6
  @loader_path = File.absolute_path("#{File.dirname(__FILE__)}/../../lib/picky/loader.rb")
7
- Configuration.stub! :apply
8
- Indexes.stub! :setup
9
7
  end
10
8
 
11
9
  describe 'load_application' do
@@ -107,11 +107,16 @@ describe 'Query::Base' do
107
107
  end
108
108
  end
109
109
 
110
+ before(:each) do
111
+ @type = stub :type
112
+ @index = stub :some_index, :index => @type
113
+ end
114
+
110
115
  describe 'initializer' do
111
116
  context 'with tokenizer' do
112
117
  before(:each) do
113
118
  @tokenizer = stub :tokenizer, :tokenize => :some_tokenized_text
114
- @query = Query::Full.new 'some query', :some_index, :tokenizer => @tokenizer
119
+ @query = Query::Full.new @index, tokenizer: @tokenizer
115
120
  end
116
121
  it 'should tokenize using the tokenizer' do
117
122
  @query.tokenized('some text').should == :some_tokenized_text
@@ -122,7 +127,7 @@ describe 'Query::Base' do
122
127
  describe "results_from" do
123
128
  describe 'Full' do
124
129
  before(:each) do
125
- @query = Query::Full.new 'some query', :some_index
130
+ @query = Query::Full.new @index
126
131
  end
127
132
  it "should work" do
128
133
  allocations = stub :allocations, :process! => true
@@ -132,7 +137,7 @@ describe 'Query::Base' do
132
137
  end
133
138
  describe 'Live' do
134
139
  before(:each) do
135
- @query = Query::Live.new 'some query', :some_index
140
+ @query = Query::Live.new @index
136
141
  end
137
142
  it "should work" do
138
143
  allocations = stub :allocations, :process! => true
@@ -142,18 +147,4 @@ describe 'Query::Base' do
142
147
  end
143
148
  end
144
149
 
145
- describe "sorted_allocations" do
146
- before(:each) do
147
- @index_class = stub :index_class
148
- @query = Query::Base.new @index_class
149
- end
150
- it "should generate the right kind of allocations" do
151
- tokens = @query.tokenized 'some query'
152
-
153
- @index_class.stub! :possible_combinations => []
154
-
155
- @query.sorted_allocations(tokens).should be_kind_of(Query::Allocations)
156
- end
157
- end
158
-
159
150
  end