picky 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/picky/{alias_instances.rb → aliases.rb} +1 -3
- data/lib/picky/application.rb +18 -19
- data/lib/picky/cores.rb +1 -1
- data/lib/picky/generators/aliases.rb +3 -0
- data/lib/picky/index/base.rb +179 -0
- data/lib/picky/index/memory.rb +28 -0
- data/lib/picky/index/redis.rb +28 -0
- data/lib/picky/{indexes_api.rb → index_bundle.rb} +16 -16
- data/lib/picky/indexed/indexes.rb +11 -7
- data/lib/picky/indexing/indexes.rb +14 -8
- data/lib/picky/internals/adapters/rack/base.rb +27 -0
- data/lib/picky/internals/adapters/rack/live_parameters.rb +37 -0
- data/lib/picky/internals/adapters/rack/query.rb +63 -0
- data/lib/picky/internals/adapters/rack.rb +34 -0
- data/lib/picky/{calculations → internals/calculations}/location.rb +0 -0
- data/lib/picky/{cli.rb → internals/cli.rb} +0 -0
- data/lib/picky/{configuration → internals/configuration}/index.rb +8 -2
- data/lib/picky/{ext → internals/ext}/maybe_compile.rb +0 -0
- data/lib/picky/{ext → internals/ext}/ruby19/extconf.rb +0 -0
- data/lib/picky/{ext → internals/ext}/ruby19/performant.c +0 -0
- data/lib/picky/{extensions → internals/extensions}/array.rb +0 -0
- data/lib/picky/{extensions → internals/extensions}/hash.rb +0 -0
- data/lib/picky/{extensions → internals/extensions}/module.rb +0 -0
- data/lib/picky/{extensions → internals/extensions}/object.rb +0 -0
- data/lib/picky/{extensions → internals/extensions}/symbol.rb +0 -0
- data/lib/picky/internals/frontend_adapters/rack.rb +154 -0
- data/lib/picky/internals/generators/base.rb +19 -0
- data/lib/picky/internals/generators/partial/default.rb +7 -0
- data/lib/picky/internals/generators/partial/none.rb +35 -0
- data/lib/picky/internals/generators/partial/strategy.rb +29 -0
- data/lib/picky/internals/generators/partial/substring.rb +122 -0
- data/lib/picky/internals/generators/partial_generator.rb +19 -0
- data/lib/picky/internals/generators/similarity/default.rb +9 -0
- data/lib/picky/internals/generators/similarity/double_levenshtone.rb +81 -0
- data/lib/picky/internals/generators/similarity/none.rb +35 -0
- data/lib/picky/internals/generators/similarity/strategy.rb +11 -0
- data/lib/picky/internals/generators/similarity_generator.rb +19 -0
- data/lib/picky/internals/generators/strategy.rb +18 -0
- data/lib/picky/internals/generators/weights/default.rb +9 -0
- data/lib/picky/internals/generators/weights/logarithmic.rb +43 -0
- data/lib/picky/internals/generators/weights/strategy.rb +11 -0
- data/lib/picky/internals/generators/weights_generator.rb +19 -0
- data/lib/picky/{helpers → internals/helpers}/measuring.rb +0 -0
- data/lib/picky/internals/index/backend.rb +113 -0
- data/lib/picky/internals/index/file/basic.rb +101 -0
- data/lib/picky/internals/index/file/json.rb +38 -0
- data/lib/picky/internals/index/file/marshal.rb +38 -0
- data/lib/picky/internals/index/file/text.rb +60 -0
- data/lib/picky/internals/index/files.rb +24 -0
- data/lib/picky/internals/index/redis/basic.rb +77 -0
- data/lib/picky/internals/index/redis/list_hash.rb +46 -0
- data/lib/picky/internals/index/redis/string_hash.rb +35 -0
- data/lib/picky/internals/index/redis.rb +44 -0
- data/lib/picky/internals/indexed/bundle/base.rb +72 -0
- data/lib/picky/internals/indexed/bundle/memory.rb +69 -0
- data/lib/picky/internals/indexed/bundle/redis.rb +70 -0
- data/lib/picky/internals/indexed/categories.rb +135 -0
- data/lib/picky/internals/indexed/category.rb +90 -0
- data/lib/picky/internals/indexed/index.rb +57 -0
- data/lib/picky/{indexed → internals/indexed}/wrappers/bundle/calculation.rb +0 -0
- data/lib/picky/{indexed → internals/indexed}/wrappers/bundle/location.rb +4 -2
- data/lib/picky/{indexed → internals/indexed}/wrappers/bundle/wrapper.rb +1 -1
- data/lib/picky/internals/indexed/wrappers/exact_first.rb +65 -0
- data/lib/picky/{indexers → internals/indexers}/no_source_specified_error.rb +0 -0
- data/lib/picky/{indexers → internals/indexers}/serial.rb +2 -2
- data/lib/picky/{indexers → internals/indexers}/solr.rb +0 -0
- data/lib/picky/internals/indexing/bundle/base.rb +219 -0
- data/lib/picky/internals/indexing/bundle/memory.rb +25 -0
- data/lib/picky/internals/indexing/bundle/redis.rb +28 -0
- data/lib/picky/internals/indexing/bundle/super_base.rb +65 -0
- data/lib/picky/internals/indexing/categories.rb +42 -0
- data/lib/picky/internals/indexing/category.rb +120 -0
- data/lib/picky/internals/indexing/index.rb +67 -0
- data/lib/picky/{performant.rb → internals/performant.rb} +0 -0
- data/lib/picky/internals/query/allocation.rb +88 -0
- data/lib/picky/internals/query/allocations.rb +137 -0
- data/lib/picky/internals/query/combination.rb +80 -0
- data/lib/picky/internals/query/combinations/base.rb +84 -0
- data/lib/picky/internals/query/combinations/memory.rb +58 -0
- data/lib/picky/internals/query/combinations/redis.rb +59 -0
- data/lib/picky/internals/query/indexes.rb +180 -0
- data/lib/picky/internals/query/qualifiers.rb +81 -0
- data/lib/picky/internals/query/token.rb +215 -0
- data/lib/picky/internals/query/tokens.rb +89 -0
- data/lib/picky/{query → internals/query}/weights.rb +0 -0
- data/lib/picky/internals/results/base.rb +106 -0
- data/lib/picky/internals/results/full.rb +17 -0
- data/lib/picky/internals/results/live.rb +17 -0
- data/lib/picky/{solr → internals/solr}/schema_generator.rb +0 -0
- data/lib/picky/internals/tokenizers/base.rb +166 -0
- data/lib/picky/internals/tokenizers/index.rb +63 -0
- data/lib/picky/internals/tokenizers/query.rb +79 -0
- data/lib/picky/loader.rb +148 -112
- data/lib/picky/query/base.rb +57 -26
- data/lib/picky/query/full.rb +1 -1
- data/lib/picky/query/live.rb +1 -1
- data/lib/picky/sources/db.rb +27 -6
- data/lib/tasks/index.rake +3 -3
- data/lib/tasks/try.rake +2 -2
- data/spec/lib/aliases_spec.rb +9 -0
- data/spec/lib/application_spec.rb +3 -3
- data/spec/lib/generators/aliases_spec.rb +1 -0
- data/spec/lib/{index_api_spec.rb → index/base_spec.rb} +7 -7
- data/spec/lib/index_bundle_spec.rb +71 -0
- data/spec/lib/indexed/indexes_spec.rb +61 -0
- data/spec/lib/indexing/indexes_spec.rb +94 -24
- data/spec/lib/{adapters → internals/adapters}/rack/base_spec.rb +2 -2
- data/spec/lib/{adapters → internals/adapters}/rack/live_parameters_spec.rb +2 -2
- data/spec/lib/{adapters → internals/adapters}/rack/query_spec.rb +2 -2
- data/spec/lib/{calculations → internals/calculations}/location_spec.rb +0 -0
- data/spec/lib/{cli_spec.rb → internals/cli_spec.rb} +4 -1
- data/spec/lib/{configuration → internals/configuration}/index_spec.rb +1 -1
- data/spec/lib/{cores_spec.rb → internals/cores_spec.rb} +0 -0
- data/spec/lib/{extensions → internals/extensions}/array_spec.rb +0 -0
- data/spec/lib/{extensions → internals/extensions}/hash_spec.rb +0 -0
- data/spec/lib/{extensions → internals/extensions}/module_spec.rb +0 -0
- data/spec/lib/{extensions → internals/extensions}/object_spec.rb +0 -0
- data/spec/lib/{extensions → internals/extensions}/symbol_spec.rb +0 -0
- data/spec/lib/{frontend_adapters → internals/frontend_adapters}/rack_spec.rb +11 -11
- data/spec/lib/{cacher → internals/generators}/cacher_strategy_spec.rb +2 -2
- data/spec/lib/internals/generators/partial/default_spec.rb +17 -0
- data/spec/lib/internals/generators/partial/none_spec.rb +17 -0
- data/spec/lib/{cacher → internals/generators}/partial/substring_spec.rb +26 -27
- data/spec/lib/{cacher → internals/generators}/partial_generator_spec.rb +5 -5
- data/spec/lib/{cacher → internals/generators}/similarity/double_levenshtone_spec.rb +4 -4
- data/spec/lib/{cacher → internals/generators}/similarity/none_spec.rb +2 -2
- data/spec/lib/{cacher → internals/generators}/similarity_generator_spec.rb +4 -4
- data/spec/lib/{cacher → internals/generators}/weights/logarithmic_spec.rb +2 -2
- data/spec/lib/internals/generators/weights_generator_spec.rb +21 -0
- data/spec/lib/{helpers → internals/helpers}/measuring_spec.rb +0 -0
- data/spec/lib/{index → internals/index}/file/basic_spec.rb +2 -2
- data/spec/lib/{index → internals/index}/file/json_spec.rb +2 -2
- data/spec/lib/{index → internals/index}/file/marshal_spec.rb +2 -2
- data/spec/lib/{index → internals/index}/file/text_spec.rb +2 -2
- data/spec/lib/{index → internals/index}/files_spec.rb +2 -2
- data/spec/lib/{indexed/bundle_spec.rb → internals/indexed/bundle/memory_spec.rb} +4 -5
- data/spec/lib/{indexed → internals/indexed}/categories_spec.rb +13 -13
- data/spec/lib/{indexed → internals/indexed}/category_spec.rb +59 -32
- data/spec/lib/{indexed → internals/indexed}/index_spec.rb +5 -5
- data/spec/lib/{indexed → internals/indexed}/wrappers/bundle/calculation_spec.rb +0 -0
- data/spec/lib/{indexed → internals/indexed}/wrappers/bundle/wrapper_spec.rb +0 -0
- data/spec/lib/{indexed → internals/indexed}/wrappers/exact_first_spec.rb +5 -5
- data/spec/lib/{indexers → internals/indexers}/serial_spec.rb +0 -0
- data/spec/lib/{indexing/bundle_partial_generation_speed_spec.rb → internals/indexing/bundle/memory_partial_generation_speed_spec.rb} +3 -3
- data/spec/lib/{indexing/bundle_spec.rb → internals/indexing/bundle/memory_spec.rb} +3 -3
- data/spec/lib/{index/bundle_spec.rb → internals/indexing/bundle/super_base_spec.rb} +9 -3
- data/spec/lib/{indexing → internals/indexing}/category_spec.rb +3 -3
- data/spec/lib/{indexing → internals/indexing}/index_spec.rb +3 -3
- data/spec/lib/internals/indexing/indexes_spec.rb +36 -0
- data/spec/lib/{interfaces → internals/interfaces}/live_parameters_spec.rb +0 -0
- data/spec/lib/internals/results/base_spec.rb +105 -0
- data/spec/lib/internals/results/full_spec.rb +78 -0
- data/spec/lib/internals/results/live_spec.rb +88 -0
- data/spec/lib/{solr → internals/solr}/schema_generator_spec.rb +0 -0
- data/spec/lib/{tokenizers → internals/tokenizers}/base_spec.rb +3 -3
- data/spec/lib/{tokenizers → internals/tokenizers}/index_spec.rb +9 -9
- data/spec/lib/{tokenizers → internals/tokenizers}/query_spec.rb +11 -11
- data/spec/lib/query/allocation_spec.rb +12 -12
- data/spec/lib/query/allocations_spec.rb +19 -19
- data/spec/lib/query/base_spec.rb +28 -4
- data/spec/lib/query/combination_spec.rb +8 -9
- data/spec/lib/query/combinations/base_spec.rb +116 -0
- data/spec/lib/query/{combinations_spec.rb → combinations/memory_spec.rb} +14 -14
- data/spec/lib/query/combinations/redis_spec.rb +132 -0
- data/spec/lib/query/full_spec.rb +2 -2
- data/spec/lib/query/indexes_spec.rb +81 -0
- data/spec/lib/query/live_spec.rb +3 -3
- data/spec/lib/query/qualifiers_spec.rb +6 -6
- data/spec/lib/query/token_spec.rb +38 -38
- data/spec/lib/query/tokens_spec.rb +35 -35
- data/spec/lib/sources/db_spec.rb +23 -18
- metadata +212 -181
- data/lib/picky/adapters/rack/base.rb +0 -23
- data/lib/picky/adapters/rack/live_parameters.rb +0 -33
- data/lib/picky/adapters/rack/query.rb +0 -59
- data/lib/picky/adapters/rack.rb +0 -28
- data/lib/picky/cacher/convenience.rb +0 -3
- data/lib/picky/cacher/generator.rb +0 -15
- data/lib/picky/cacher/partial/default.rb +0 -5
- data/lib/picky/cacher/partial/none.rb +0 -31
- data/lib/picky/cacher/partial/strategy.rb +0 -21
- data/lib/picky/cacher/partial/substring.rb +0 -118
- data/lib/picky/cacher/partial_generator.rb +0 -15
- data/lib/picky/cacher/similarity/default.rb +0 -7
- data/lib/picky/cacher/similarity/double_levenshtone.rb +0 -77
- data/lib/picky/cacher/similarity/none.rb +0 -31
- data/lib/picky/cacher/similarity/strategy.rb +0 -9
- data/lib/picky/cacher/similarity_generator.rb +0 -15
- data/lib/picky/cacher/strategy.rb +0 -12
- data/lib/picky/cacher/weights/default.rb +0 -7
- data/lib/picky/cacher/weights/logarithmic.rb +0 -39
- data/lib/picky/cacher/weights/strategy.rb +0 -9
- data/lib/picky/cacher/weights_generator.rb +0 -15
- data/lib/picky/frontend_adapters/rack.rb +0 -150
- data/lib/picky/index/bundle.rb +0 -54
- data/lib/picky/index/file/basic.rb +0 -97
- data/lib/picky/index/file/json.rb +0 -34
- data/lib/picky/index/file/marshal.rb +0 -34
- data/lib/picky/index/file/text.rb +0 -56
- data/lib/picky/index/files.rb +0 -118
- data/lib/picky/index_api.rb +0 -175
- data/lib/picky/indexed/bundle.rb +0 -54
- data/lib/picky/indexed/categories.rb +0 -131
- data/lib/picky/indexed/category.rb +0 -85
- data/lib/picky/indexed/index.rb +0 -39
- data/lib/picky/indexed/wrappers/exact_first.rb +0 -61
- data/lib/picky/indexing/bundle.rb +0 -213
- data/lib/picky/indexing/categories.rb +0 -38
- data/lib/picky/indexing/category.rb +0 -117
- data/lib/picky/indexing/index.rb +0 -55
- data/lib/picky/query/allocation.rb +0 -82
- data/lib/picky/query/allocations.rb +0 -130
- data/lib/picky/query/combination.rb +0 -74
- data/lib/picky/query/combinations.rb +0 -105
- data/lib/picky/query/qualifiers.rb +0 -77
- data/lib/picky/query/token.rb +0 -202
- data/lib/picky/query/tokens.rb +0 -86
- data/lib/picky/query/weigher.rb +0 -165
- data/lib/picky/results/base.rb +0 -102
- data/lib/picky/results/full.rb +0 -13
- data/lib/picky/results/live.rb +0 -13
- data/lib/picky/tokenizers/base.rb +0 -161
- data/lib/picky/tokenizers/index.rb +0 -58
- data/lib/picky/tokenizers/query.rb +0 -74
- data/spec/lib/cacher/partial/default_spec.rb +0 -15
- data/spec/lib/cacher/partial/none_spec.rb +0 -17
- data/spec/lib/cacher/weights_generator_spec.rb +0 -21
- data/spec/lib/results/base_spec.rb +0 -257
- data/spec/lib/results/live_spec.rb +0 -15
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Query::Allocations do
|
|
3
|
+
describe Internals::Query::Allocations do
|
|
4
4
|
|
|
5
5
|
describe 'reduce_to' do
|
|
6
6
|
before(:each) do
|
|
7
7
|
@allocation1 = stub :allocation1
|
|
8
8
|
@allocation2 = stub :allocation2
|
|
9
9
|
@allocation3 = stub :allocation3
|
|
10
|
-
@allocations =
|
|
10
|
+
@allocations = described_class.new [@allocation1, @allocation2, @allocation3]
|
|
11
11
|
end
|
|
12
12
|
it 'should do nothing' do
|
|
13
13
|
@allocations.reduce_to 2
|
|
@@ -21,7 +21,7 @@ describe Query::Allocations do
|
|
|
21
21
|
@allocation1 = stub :allocation1
|
|
22
22
|
@allocation2 = stub :allocation2
|
|
23
23
|
@allocation3 = stub :allocation3
|
|
24
|
-
@allocations =
|
|
24
|
+
@allocations = described_class.new [@allocation1, @allocation2, @allocation3]
|
|
25
25
|
end
|
|
26
26
|
context 'identifiers empty' do
|
|
27
27
|
it 'should do nothing' do
|
|
@@ -47,7 +47,7 @@ describe Query::Allocations do
|
|
|
47
47
|
@allocation1 = stub :allocation1
|
|
48
48
|
@allocation2 = stub :allocation2
|
|
49
49
|
@allocation3 = stub :allocation3
|
|
50
|
-
@allocations =
|
|
50
|
+
@allocations = described_class.new [@allocation1, @allocation2, @allocation3]
|
|
51
51
|
end
|
|
52
52
|
context 'identifiers empty' do
|
|
53
53
|
it 'should do nothing' do
|
|
@@ -74,7 +74,7 @@ describe Query::Allocations do
|
|
|
74
74
|
@allocation1 = stub :allocation1, :ids => [1, 2, 3, 4]
|
|
75
75
|
@allocation2 = stub :allocation2, :ids => [5, 6, 7]
|
|
76
76
|
@allocation3 = stub :allocation3, :ids => [8, 9]
|
|
77
|
-
@allocations =
|
|
77
|
+
@allocations = described_class.new [@allocation1, @allocation2, @allocation3]
|
|
78
78
|
end
|
|
79
79
|
it 'should return the right amount of ids' do
|
|
80
80
|
@allocations.ids(0).should == []
|
|
@@ -91,7 +91,7 @@ describe Query::Allocations do
|
|
|
91
91
|
@allocation1 = stub :allocation1, :ids => [:a, :b, :c, :d]
|
|
92
92
|
@allocation2 = stub :allocation2, :ids => [:e, :f, :g]
|
|
93
93
|
@allocation3 = stub :allocation3, :ids => [:h, :i]
|
|
94
|
-
@allocations =
|
|
94
|
+
@allocations = described_class.new [@allocation1, @allocation2, @allocation3]
|
|
95
95
|
end
|
|
96
96
|
it 'should return the right amount of ids' do
|
|
97
97
|
@allocations.ids(0).should == []
|
|
@@ -110,7 +110,7 @@ describe Query::Allocations do
|
|
|
110
110
|
@allocation1 = stub :allocation1, :process! => [], :count => 4 #, ids: [1, 2, 3, 4]
|
|
111
111
|
@allocation2 = stub :allocation2, :process! => [], :count => 3 #, ids: [5, 6, 7]
|
|
112
112
|
@allocation3 = stub :allocation3, :process! => [], :count => 2 #, ids: [8, 9]
|
|
113
|
-
@allocations =
|
|
113
|
+
@allocations = described_class.new [@allocation1, @allocation2, @allocation3]
|
|
114
114
|
end
|
|
115
115
|
describe 'amount spanning 3 allocations' do
|
|
116
116
|
before(:each) do
|
|
@@ -184,7 +184,7 @@ describe Query::Allocations do
|
|
|
184
184
|
before(:each) do
|
|
185
185
|
@allocation1 = stub :allocation1, :ids => [1, 2, 3]
|
|
186
186
|
@allocation2 = stub :allocation2, :ids => [4, 5, 6, 7]
|
|
187
|
-
@allocations =
|
|
187
|
+
@allocations = described_class.new [@allocation1, @allocation2]
|
|
188
188
|
end
|
|
189
189
|
it 'should return one random id from the first allocations by default' do
|
|
190
190
|
@allocations.random_ids.size.should == 1
|
|
@@ -205,7 +205,7 @@ describe Query::Allocations do
|
|
|
205
205
|
before(:each) do
|
|
206
206
|
@allocation1 = stub :allocation1, :ids => [1]
|
|
207
207
|
@allocation2 = stub :allocation2, :ids => []
|
|
208
|
-
@allocations =
|
|
208
|
+
@allocations = described_class.new [@allocation1, @allocation2]
|
|
209
209
|
end
|
|
210
210
|
it 'should return one random id from its allocations by default' do
|
|
211
211
|
@allocations.random_ids.size.should == 1
|
|
@@ -221,7 +221,7 @@ describe Query::Allocations do
|
|
|
221
221
|
before(:each) do
|
|
222
222
|
@allocation1 = stub :allocation1, :ids => []
|
|
223
223
|
@allocation2 = stub :allocation2, :ids => []
|
|
224
|
-
@allocations =
|
|
224
|
+
@allocations = described_class.new [@allocation1, @allocation2]
|
|
225
225
|
end
|
|
226
226
|
it 'should return one random id from its allocations by default' do
|
|
227
227
|
@allocations.random_ids.size.should == 0
|
|
@@ -239,7 +239,7 @@ describe Query::Allocations do
|
|
|
239
239
|
context 'all allocations have results' do
|
|
240
240
|
before(:each) do
|
|
241
241
|
@allocation = stub :allocation
|
|
242
|
-
@allocations =
|
|
242
|
+
@allocations = described_class.new [@allocation, @allocation, @allocation]
|
|
243
243
|
end
|
|
244
244
|
it 'should delegate to each allocation with no params' do
|
|
245
245
|
@allocation.should_receive(:to_result).exactly(3).times.with
|
|
@@ -251,7 +251,7 @@ describe Query::Allocations do
|
|
|
251
251
|
before(:each) do
|
|
252
252
|
@allocation = stub :allocation, :to_result => :some_result
|
|
253
253
|
@no_result_allocation = stub :no_results, :to_result => nil
|
|
254
|
-
@allocations =
|
|
254
|
+
@allocations = described_class.new [@allocation, @no_result_allocation, @allocation]
|
|
255
255
|
end
|
|
256
256
|
it 'should delegate to each allocation with the same params' do
|
|
257
257
|
@allocations.to_result.should == [:some_result, :some_result]
|
|
@@ -262,7 +262,7 @@ describe Query::Allocations do
|
|
|
262
262
|
describe 'total' do
|
|
263
263
|
context 'with allocations' do
|
|
264
264
|
before(:each) do
|
|
265
|
-
@allocations =
|
|
265
|
+
@allocations = described_class.new [
|
|
266
266
|
stub(:allocation, :process! => (1..10).to_a, :count => 10),
|
|
267
267
|
stub(:allocation, :process! => (1..80).to_a, :count => 80),
|
|
268
268
|
stub(:allocation, :process! => (1..20).to_a, :count => 20)
|
|
@@ -276,7 +276,7 @@ describe Query::Allocations do
|
|
|
276
276
|
end
|
|
277
277
|
context 'without allocations' do
|
|
278
278
|
before(:each) do
|
|
279
|
-
@allocations =
|
|
279
|
+
@allocations = described_class.new []
|
|
280
280
|
end
|
|
281
281
|
it 'should be 0' do
|
|
282
282
|
@allocations.process! 20, 0
|
|
@@ -289,7 +289,7 @@ describe Query::Allocations do
|
|
|
289
289
|
describe "each" do
|
|
290
290
|
before(:each) do
|
|
291
291
|
@internal_allocations = mock :internal_allocations
|
|
292
|
-
@allocations =
|
|
292
|
+
@allocations = described_class.new @internal_allocations
|
|
293
293
|
end
|
|
294
294
|
it "should delegate to the internal allocations" do
|
|
295
295
|
stub_proc = lambda {}
|
|
@@ -301,7 +301,7 @@ describe Query::Allocations do
|
|
|
301
301
|
describe "inject" do
|
|
302
302
|
before(:each) do
|
|
303
303
|
@internal_allocations = mock :internal_allocations
|
|
304
|
-
@allocations =
|
|
304
|
+
@allocations = described_class.new @internal_allocations
|
|
305
305
|
end
|
|
306
306
|
it "should delegate to the internal allocations" do
|
|
307
307
|
stub_proc = lambda {}
|
|
@@ -313,7 +313,7 @@ describe Query::Allocations do
|
|
|
313
313
|
describe "empty?" do
|
|
314
314
|
before(:each) do
|
|
315
315
|
@internal_allocations = mock :internal_allocations
|
|
316
|
-
@allocations =
|
|
316
|
+
@allocations = described_class.new @internal_allocations
|
|
317
317
|
end
|
|
318
318
|
it "should delegate to the internal allocations array" do
|
|
319
319
|
@internal_allocations.should_receive(:empty?).once
|
|
@@ -324,7 +324,7 @@ describe Query::Allocations do
|
|
|
324
324
|
describe "to_s" do
|
|
325
325
|
before(:each) do
|
|
326
326
|
@internal_allocations = mock :internal_allocations
|
|
327
|
-
@allocations =
|
|
327
|
+
@allocations = described_class.new @internal_allocations
|
|
328
328
|
end
|
|
329
329
|
it "should delegate to the internal allocations array" do
|
|
330
330
|
@internal_allocations.should_receive(:inspect).once
|
|
@@ -335,7 +335,7 @@ describe Query::Allocations do
|
|
|
335
335
|
describe "process!" do
|
|
336
336
|
context 'some allocations' do
|
|
337
337
|
before(:each) do
|
|
338
|
-
@allocations =
|
|
338
|
+
@allocations = described_class.new [
|
|
339
339
|
stub(:allocation, :process! => (1..10).to_a, :count => 10),
|
|
340
340
|
stub(:allocation, :process! => (1..80).to_a, :count => 80),
|
|
341
341
|
stub(:allocation, :process! => (1..20).to_a, :count => 20)
|
data/spec/lib/query/base_spec.rb
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
|
+
#
|
|
2
3
|
require 'spec_helper'
|
|
3
4
|
|
|
4
|
-
describe
|
|
5
|
+
describe Query::Base do
|
|
6
|
+
|
|
7
|
+
describe 'combinations_type_for' do
|
|
8
|
+
let(:query) { described_class.new }
|
|
9
|
+
it 'returns a specific Combination for a specific input' do
|
|
10
|
+
query.combinations_type_for([Index::Memory.new(:gu, :ga)]).should == Internals::Query::Combinations::Memory
|
|
11
|
+
end
|
|
12
|
+
it 'just works on the same types' do
|
|
13
|
+
query.combinations_type_for([:blorf, :blarf]).should == Internals::Query::Combinations::Memory
|
|
14
|
+
end
|
|
15
|
+
it 'just uses standard combinations' do
|
|
16
|
+
query.combinations_type_for([:blorf]).should == Internals::Query::Combinations::Memory
|
|
17
|
+
end
|
|
18
|
+
it 'raises on multiple types' do
|
|
19
|
+
expect do
|
|
20
|
+
query.combinations_type_for [:blorf, "blarf"]
|
|
21
|
+
end.to raise_error(Query::Base::DifferentTypesError)
|
|
22
|
+
end
|
|
23
|
+
it 'raises with the right message on multiple types' do
|
|
24
|
+
expect do
|
|
25
|
+
query.combinations_type_for [:blorf, "blarf"]
|
|
26
|
+
end.to raise_error("Currently it isn't possible to mix Symbol and String Indexes in the same Query.")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
5
29
|
|
|
6
30
|
describe "weights handling" do
|
|
7
31
|
it "creates a default weight when no weights are given" do
|
|
8
|
-
query =
|
|
32
|
+
query = described_class.new
|
|
9
33
|
|
|
10
34
|
query.weights.should be_kind_of(Query::Weights)
|
|
11
35
|
end
|
|
12
36
|
it "handles :weights options when not yet wrapped" do
|
|
13
|
-
query =
|
|
37
|
+
query = described_class.new :weights => { [:a, :b] => +3 }
|
|
14
38
|
|
|
15
39
|
query.weights.should be_kind_of(Query::Weights)
|
|
16
40
|
end
|
|
17
41
|
it "handles :weights options when already wrapped" do
|
|
18
|
-
query =
|
|
42
|
+
query = described_class.new :weights => Query::Weights.new([:a, :b] => +3)
|
|
19
43
|
|
|
20
44
|
query.weights.should be_kind_of(Query::Weights)
|
|
21
45
|
end
|
|
@@ -6,10 +6,10 @@ describe 'Query::Combination' do
|
|
|
6
6
|
|
|
7
7
|
before(:each) do
|
|
8
8
|
@bundle = stub :bundle, :identifier => :bundle_name
|
|
9
|
-
@token =
|
|
9
|
+
@token = Internals::Query::Token.processed('some_text~')
|
|
10
10
|
@category = stub :category, :bundle_for => @bundle, :name => :some_category_name
|
|
11
11
|
|
|
12
|
-
@combination = Query::Combination.new @token, @category
|
|
12
|
+
@combination = Internals::Query::Combination.new @token, @category
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
describe "to_s" do
|
|
@@ -41,9 +41,9 @@ describe 'Query::Combination' do
|
|
|
41
41
|
describe 'to_result' do
|
|
42
42
|
context 'functional with qualifier' do
|
|
43
43
|
before(:each) do
|
|
44
|
-
token = Tokenizers::Query.new.tokenize('name:Blä~').first
|
|
44
|
+
token = Internals::Tokenizers::Query.new.tokenize('name:Blä~').first
|
|
45
45
|
|
|
46
|
-
@combination = Query::Combination.new token, @category
|
|
46
|
+
@combination = Internals::Query::Combination.new token, @category
|
|
47
47
|
end
|
|
48
48
|
it 'should return a correct result' do
|
|
49
49
|
@combination.to_result.should == [:some_category_name, 'Blä~', :blä] # Note: Characters not substituted. That's ok.
|
|
@@ -51,21 +51,20 @@ describe 'Query::Combination' do
|
|
|
51
51
|
end
|
|
52
52
|
it 'should return a correct result' do
|
|
53
53
|
@token.stub! :to_result => [:some_original_text, :some_text]
|
|
54
|
-
@combination.stub! :identifier => :some_identifier
|
|
55
54
|
|
|
56
|
-
@combination.to_result.should == [:
|
|
55
|
+
@combination.to_result.should == [:some_category_name, :some_original_text, :some_text]
|
|
57
56
|
end
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
describe 'identifier' do
|
|
61
60
|
it 'should get the category name from the bundle' do
|
|
62
|
-
@combination.identifier.should == :
|
|
61
|
+
@combination.identifier.should == "bundle_name:similarity:some_text"
|
|
63
62
|
end
|
|
64
63
|
end
|
|
65
64
|
|
|
66
65
|
describe 'ids' do
|
|
67
66
|
it 'should call ids with the text on bundle' do
|
|
68
|
-
@bundle.should_receive(:ids).once.with
|
|
67
|
+
@bundle.should_receive(:ids).once.with 'some_text'
|
|
69
68
|
|
|
70
69
|
@combination.ids
|
|
71
70
|
end
|
|
@@ -81,7 +80,7 @@ describe 'Query::Combination' do
|
|
|
81
80
|
|
|
82
81
|
describe 'weight' do
|
|
83
82
|
it 'should call weight with the text on bundle' do
|
|
84
|
-
@bundle.should_receive(:weight).once.with
|
|
83
|
+
@bundle.should_receive(:weight).once.with 'some_text'
|
|
85
84
|
|
|
86
85
|
@combination.weight
|
|
87
86
|
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
#
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Internals::Query::Combinations::Base do
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
@combinations_ary = stub :combinations_ary
|
|
9
|
+
|
|
10
|
+
@combinations = described_class.new @combinations_ary
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "pack_into_allocation" do
|
|
14
|
+
it "return an Allocation" do
|
|
15
|
+
@combinations.pack_into_allocation(:some_result_identifier).should be_kind_of(Internals::Query::Allocation)
|
|
16
|
+
end
|
|
17
|
+
it "returns an Allocation with specific result_identifier" do
|
|
18
|
+
@combinations.pack_into_allocation(:some_result_identifier).result_identifier.should == :some_result_identifier
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "to_result" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@combination1 = stub :combination1, :to_result => :result1
|
|
25
|
+
@combination2 = stub :combination2, :to_result => :result2
|
|
26
|
+
|
|
27
|
+
@combinations_ary = [@combination1, @combination2]
|
|
28
|
+
|
|
29
|
+
@combinations = described_class.new @combinations_ary
|
|
30
|
+
end
|
|
31
|
+
it "resultifies the combinations" do
|
|
32
|
+
@combinations.to_result.should == [:result1, :result2]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "weighted_score" do
|
|
37
|
+
it "uses the weights' score method" do
|
|
38
|
+
weights = stub :weights
|
|
39
|
+
weights.should_receive(:score).once.with @combinations_ary
|
|
40
|
+
|
|
41
|
+
@combinations.weighted_score weights
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "total_score" do
|
|
46
|
+
before(:each) do
|
|
47
|
+
@combination1 = stub :combination1, :weight => 3.14
|
|
48
|
+
@combination2 = stub :combination2, :weight => 2.76
|
|
49
|
+
|
|
50
|
+
@combinations_ary = [@combination1, @combination2]
|
|
51
|
+
|
|
52
|
+
@combinations = described_class.new @combinations_ary
|
|
53
|
+
end
|
|
54
|
+
it "sums the scores" do
|
|
55
|
+
@combinations.total_score.should == 5.90
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "calculate_score" do
|
|
60
|
+
before(:each) do
|
|
61
|
+
@combinations.stub! :total_score => 0
|
|
62
|
+
@combinations.stub! :weighted_score => 0
|
|
63
|
+
end
|
|
64
|
+
it "first sums, then weighs" do
|
|
65
|
+
@combinations.should_receive(:total_score).once.ordered.and_return 0
|
|
66
|
+
@combinations.should_receive(:weighted_score).once.ordered.and_return 0
|
|
67
|
+
|
|
68
|
+
@combinations.calculate_score :anything
|
|
69
|
+
end
|
|
70
|
+
it "calls sum_score" do
|
|
71
|
+
@combinations.should_receive(:total_score).once.with.and_return 0
|
|
72
|
+
|
|
73
|
+
@combinations.calculate_score :anything
|
|
74
|
+
end
|
|
75
|
+
it "calls sum_score" do
|
|
76
|
+
@combinations.should_receive(:weighted_score).once.with(:weights).and_return 0
|
|
77
|
+
|
|
78
|
+
@combinations.calculate_score :weights
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe 'hash' do
|
|
83
|
+
it "delegates to the combinations array" do
|
|
84
|
+
@combinations_ary.should_receive(:hash).once.with
|
|
85
|
+
|
|
86
|
+
@combinations.hash
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe 'remove' do
|
|
91
|
+
before(:each) do
|
|
92
|
+
@combination1 = stub :combination1, :in? => false
|
|
93
|
+
@combination2 = stub :combination2, :in? => true
|
|
94
|
+
@combination3 = stub :combination3, :in? => true
|
|
95
|
+
|
|
96
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
97
|
+
end
|
|
98
|
+
it 'should remove the combinations' do
|
|
99
|
+
@combinations.remove([:any]).should == [@combination1]
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe 'keep' do
|
|
104
|
+
before(:each) do
|
|
105
|
+
@combination1 = stub :combination1, :in? => false
|
|
106
|
+
@combination2 = stub :combination2, :in? => true
|
|
107
|
+
@combination3 = stub :combination3, :in? => true
|
|
108
|
+
|
|
109
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
110
|
+
end
|
|
111
|
+
it 'should filter the combinations' do
|
|
112
|
+
@combinations.keep([:any]).should == [@combination2, @combination3]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
#
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
describe
|
|
5
|
+
describe Internals::Query::Combinations::Memory do
|
|
6
6
|
|
|
7
7
|
before(:each) do
|
|
8
8
|
@combinations_ary = stub :combinations_ary
|
|
9
9
|
|
|
10
|
-
@combinations =
|
|
10
|
+
@combinations = described_class.new @combinations_ary
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
describe "pack_into_allocation" do
|
|
14
14
|
it "return an Allocation" do
|
|
15
|
-
@combinations.pack_into_allocation(:some_result_identifier).should be_kind_of(Query::Allocation)
|
|
15
|
+
@combinations.pack_into_allocation(:some_result_identifier).should be_kind_of(Internals::Query::Allocation)
|
|
16
16
|
end
|
|
17
17
|
it "returns an Allocation with specific result_identifier" do
|
|
18
18
|
@combinations.pack_into_allocation(:some_result_identifier).result_identifier.should == :some_result_identifier
|
|
@@ -26,7 +26,7 @@ describe 'Query::Combinations' do
|
|
|
26
26
|
|
|
27
27
|
@combinations_ary = [@combination1, @combination2]
|
|
28
28
|
|
|
29
|
-
@combinations =
|
|
29
|
+
@combinations = described_class.new @combinations_ary
|
|
30
30
|
end
|
|
31
31
|
it "resultifies the combinations" do
|
|
32
32
|
@combinations.to_result.should == [:result1, :result2]
|
|
@@ -49,7 +49,7 @@ describe 'Query::Combinations' do
|
|
|
49
49
|
|
|
50
50
|
@combinations_ary = [@combination1, @combination2]
|
|
51
51
|
|
|
52
|
-
@combinations =
|
|
52
|
+
@combinations = described_class.new @combinations_ary
|
|
53
53
|
end
|
|
54
54
|
it "sums the scores" do
|
|
55
55
|
@combinations.total_score.should == 5.90
|
|
@@ -93,7 +93,7 @@ describe 'Query::Combinations' do
|
|
|
93
93
|
@combination2 = stub :combination2, :in? => true
|
|
94
94
|
@combination3 = stub :combination3, :in? => true
|
|
95
95
|
|
|
96
|
-
@combinations =
|
|
96
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
97
97
|
end
|
|
98
98
|
it 'should remove the combinations' do
|
|
99
99
|
@combinations.remove([:any]).should == [@combination1]
|
|
@@ -106,7 +106,7 @@ describe 'Query::Combinations' do
|
|
|
106
106
|
@combination2 = stub :combination2, :in? => true
|
|
107
107
|
@combination3 = stub :combination3, :in? => true
|
|
108
108
|
|
|
109
|
-
@combinations =
|
|
109
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
110
110
|
end
|
|
111
111
|
it 'should filter the combinations' do
|
|
112
112
|
@combinations.keep([:any]).should == [@combination2, @combination3]
|
|
@@ -118,49 +118,49 @@ describe 'Query::Combinations' do
|
|
|
118
118
|
@combination1 = stub :combination1
|
|
119
119
|
@combination2 = stub :combination2
|
|
120
120
|
@combination3 = stub :combination3
|
|
121
|
-
@combinations =
|
|
121
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
122
122
|
end
|
|
123
123
|
it "should intersect correctly" do
|
|
124
124
|
@combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
|
|
125
125
|
@combination2.should_receive(:ids).once.with.and_return (1..100).to_a
|
|
126
126
|
@combination3.should_receive(:ids).once.with.and_return (1..10).to_a
|
|
127
127
|
|
|
128
|
-
@combinations.ids.should == (1..10).to_a
|
|
128
|
+
@combinations.ids(:any, :thing).should == (1..10).to_a
|
|
129
129
|
end
|
|
130
130
|
it "should intersect symbol_keys correctly" do
|
|
131
131
|
@combination1.should_receive(:ids).once.with.and_return (:'00001'..:'10000').to_a
|
|
132
132
|
@combination2.should_receive(:ids).once.with.and_return (:'00001'..:'00100').to_a
|
|
133
133
|
@combination3.should_receive(:ids).once.with.and_return (:'00001'..:'00010').to_a
|
|
134
134
|
|
|
135
|
-
@combinations.ids.should == (:'00001'..:'0010').to_a
|
|
135
|
+
@combinations.ids(:any, :thing).should == (:'00001'..:'0010').to_a
|
|
136
136
|
end
|
|
137
137
|
it "should intersect correctly when intermediate intersect result is empty" do
|
|
138
138
|
@combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
|
|
139
139
|
@combination2.should_receive(:ids).once.with.and_return (11..100).to_a
|
|
140
140
|
@combination3.should_receive(:ids).once.with.and_return (1..10).to_a
|
|
141
141
|
|
|
142
|
-
@combinations.ids.should == []
|
|
142
|
+
@combinations.ids(:any, :thing).should == []
|
|
143
143
|
end
|
|
144
144
|
it "should be fast" do
|
|
145
145
|
@combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
|
|
146
146
|
@combination2.should_receive(:ids).once.with.and_return (1..100).to_a
|
|
147
147
|
@combination3.should_receive(:ids).once.with.and_return (1..10).to_a
|
|
148
148
|
|
|
149
|
-
performance_of { @combinations.ids }.should < 0.004
|
|
149
|
+
performance_of { @combinations.ids(:any, :thing) }.should < 0.004
|
|
150
150
|
end
|
|
151
151
|
it "should be fast" do
|
|
152
152
|
@combination1.should_receive(:ids).once.with.and_return (1..1000).to_a
|
|
153
153
|
@combination2.should_receive(:ids).once.with.and_return (1..100).to_a
|
|
154
154
|
@combination3.should_receive(:ids).once.with.and_return (1..10).to_a
|
|
155
155
|
|
|
156
|
-
performance_of { @combinations.ids }.should < 0.00015
|
|
156
|
+
performance_of { @combinations.ids(:any, :thing) }.should < 0.00015
|
|
157
157
|
end
|
|
158
158
|
it "should be fast" do
|
|
159
159
|
@combination1.should_receive(:ids).once.with.and_return (1..1000).to_a
|
|
160
160
|
@combination2.should_receive(:ids).once.with.and_return (901..1000).to_a
|
|
161
161
|
@combination3.should_receive(:ids).once.with.and_return (1..10).to_a
|
|
162
162
|
|
|
163
|
-
performance_of { @combinations.ids }.should < 0.0001
|
|
163
|
+
performance_of { @combinations.ids(:any, :thing) }.should < 0.0001
|
|
164
164
|
end
|
|
165
165
|
end
|
|
166
166
|
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
#
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Internals::Query::Combinations::Redis do
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
@combinations_ary = stub :combinations_ary
|
|
9
|
+
|
|
10
|
+
@combinations = described_class.new @combinations_ary
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "pack_into_allocation" do
|
|
14
|
+
it "return an Allocation" do
|
|
15
|
+
@combinations.pack_into_allocation(:some_result_identifier).should be_kind_of(Internals::Query::Allocation)
|
|
16
|
+
end
|
|
17
|
+
it "returns an Allocation with specific result_identifier" do
|
|
18
|
+
@combinations.pack_into_allocation(:some_result_identifier).result_identifier.should == :some_result_identifier
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "to_result" do
|
|
23
|
+
before(:each) do
|
|
24
|
+
@combination1 = stub :combination1, :to_result => :result1
|
|
25
|
+
@combination2 = stub :combination2, :to_result => :result2
|
|
26
|
+
|
|
27
|
+
@combinations_ary = [@combination1, @combination2]
|
|
28
|
+
|
|
29
|
+
@combinations = described_class.new @combinations_ary
|
|
30
|
+
end
|
|
31
|
+
it "resultifies the combinations" do
|
|
32
|
+
@combinations.to_result.should == [:result1, :result2]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "weighted_score" do
|
|
37
|
+
it "uses the weights' score method" do
|
|
38
|
+
weights = stub :weights
|
|
39
|
+
weights.should_receive(:score).once.with @combinations_ary
|
|
40
|
+
|
|
41
|
+
@combinations.weighted_score weights
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "total_score" do
|
|
46
|
+
before(:each) do
|
|
47
|
+
@combination1 = stub :combination1, :weight => 3.14
|
|
48
|
+
@combination2 = stub :combination2, :weight => 2.76
|
|
49
|
+
|
|
50
|
+
@combinations_ary = [@combination1, @combination2]
|
|
51
|
+
|
|
52
|
+
@combinations = described_class.new @combinations_ary
|
|
53
|
+
end
|
|
54
|
+
it "sums the scores" do
|
|
55
|
+
@combinations.total_score.should == 5.90
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "calculate_score" do
|
|
60
|
+
before(:each) do
|
|
61
|
+
@combinations.stub! :total_score => 0
|
|
62
|
+
@combinations.stub! :weighted_score => 0
|
|
63
|
+
end
|
|
64
|
+
it "first sums, then weighs" do
|
|
65
|
+
@combinations.should_receive(:total_score).once.ordered.and_return 0
|
|
66
|
+
@combinations.should_receive(:weighted_score).once.ordered.and_return 0
|
|
67
|
+
|
|
68
|
+
@combinations.calculate_score :anything
|
|
69
|
+
end
|
|
70
|
+
it "calls sum_score" do
|
|
71
|
+
@combinations.should_receive(:total_score).once.with.and_return 0
|
|
72
|
+
|
|
73
|
+
@combinations.calculate_score :anything
|
|
74
|
+
end
|
|
75
|
+
it "calls sum_score" do
|
|
76
|
+
@combinations.should_receive(:weighted_score).once.with(:weights).and_return 0
|
|
77
|
+
|
|
78
|
+
@combinations.calculate_score :weights
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe 'hash' do
|
|
83
|
+
it "delegates to the combinations array" do
|
|
84
|
+
@combinations_ary.should_receive(:hash).once.with
|
|
85
|
+
|
|
86
|
+
@combinations.hash
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe 'remove' do
|
|
91
|
+
before(:each) do
|
|
92
|
+
@combination1 = stub :combination1, :in? => false
|
|
93
|
+
@combination2 = stub :combination2, :in? => true
|
|
94
|
+
@combination3 = stub :combination3, :in? => true
|
|
95
|
+
|
|
96
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
97
|
+
end
|
|
98
|
+
it 'should remove the combinations' do
|
|
99
|
+
@combinations.remove([:any]).should == [@combination1]
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe 'keep' do
|
|
104
|
+
before(:each) do
|
|
105
|
+
@combination1 = stub :combination1, :in? => false
|
|
106
|
+
@combination2 = stub :combination2, :in? => true
|
|
107
|
+
@combination3 = stub :combination3, :in? => true
|
|
108
|
+
|
|
109
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
110
|
+
end
|
|
111
|
+
it 'should filter the combinations' do
|
|
112
|
+
@combinations.keep([:any]).should == [@combination2, @combination3]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe 'generate_intermediate_result_id' do
|
|
117
|
+
# TODO
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
describe "ids" do
|
|
121
|
+
before(:each) do
|
|
122
|
+
@combination1 = stub :combination1, :identifier => 'cat1'
|
|
123
|
+
@combination2 = stub :combination2, :identifier => 'cat2'
|
|
124
|
+
@combination3 = stub :combination3, :identifier => 'cat3'
|
|
125
|
+
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
|
126
|
+
end
|
|
127
|
+
it 'calls the redis client correctly' do
|
|
128
|
+
# TODO
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
end
|
data/spec/lib/query/full_spec.rb
CHANGED
|
@@ -9,10 +9,10 @@ describe Query::Full do
|
|
|
9
9
|
|
|
10
10
|
describe 'result_type' do
|
|
11
11
|
before(:each) do
|
|
12
|
-
@query =
|
|
12
|
+
@query = described_class.new @index
|
|
13
13
|
end
|
|
14
14
|
it "should return a specific type" do
|
|
15
|
-
@query.result_type.should == Results::Full
|
|
15
|
+
@query.result_type.should == Internals::Results::Full
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|