sunspot 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/Appraisals +7 -0
  5. data/Gemfile +0 -8
  6. data/gemfiles/.gitkeep +0 -0
  7. data/lib/sunspot/dsl/scope.rb +6 -1
  8. data/lib/sunspot/field.rb +11 -0
  9. data/lib/sunspot/field_factory.rb +6 -2
  10. data/lib/sunspot/query/bbox.rb +5 -1
  11. data/lib/sunspot/query/restriction.rb +11 -0
  12. data/lib/sunspot/search/hit_enumerable.rb +4 -1
  13. data/lib/sunspot/search/standard_search.rb +2 -3
  14. data/lib/sunspot/version.rb +1 -1
  15. data/spec/api/adapters_spec.rb +19 -19
  16. data/spec/api/batcher_spec.rb +15 -15
  17. data/spec/api/binding_spec.rb +3 -3
  18. data/spec/api/class_set_spec.rb +3 -3
  19. data/spec/api/hit_enumerable_spec.rb +32 -9
  20. data/spec/api/indexer/attributes_spec.rb +31 -31
  21. data/spec/api/indexer/batch_spec.rb +8 -7
  22. data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
  23. data/spec/api/indexer/fixed_fields_spec.rb +12 -12
  24. data/spec/api/indexer/fulltext_spec.rb +8 -8
  25. data/spec/api/indexer/removal_spec.rb +14 -14
  26. data/spec/api/indexer_spec.rb +2 -2
  27. data/spec/api/query/advanced_manipulation_examples.rb +3 -3
  28. data/spec/api/query/connectives_examples.rb +26 -14
  29. data/spec/api/query/dsl_spec.rb +17 -9
  30. data/spec/api/query/dynamic_fields_examples.rb +18 -18
  31. data/spec/api/query/faceting_examples.rb +62 -62
  32. data/spec/api/query/fulltext_examples.rb +56 -55
  33. data/spec/api/query/function_spec.rb +26 -26
  34. data/spec/api/query/geo_examples.rb +6 -6
  35. data/spec/api/query/group_spec.rb +6 -6
  36. data/spec/api/query/highlighting_examples.rb +26 -26
  37. data/spec/api/query/join_spec.rb +2 -2
  38. data/spec/api/query/more_like_this_spec.rb +29 -29
  39. data/spec/api/query/ordering_pagination_examples.rb +25 -25
  40. data/spec/api/query/scope_examples.rb +39 -39
  41. data/spec/api/query/spatial_examples.rb +3 -3
  42. data/spec/api/query/spellcheck_examples.rb +3 -3
  43. data/spec/api/query/standard_spec.rb +1 -1
  44. data/spec/api/query/stats_examples.rb +8 -8
  45. data/spec/api/query/text_field_scoping_examples.rb +5 -5
  46. data/spec/api/query/types_spec.rb +4 -4
  47. data/spec/api/search/cursor_paginated_collection_spec.rb +12 -12
  48. data/spec/api/search/dynamic_fields_spec.rb +4 -4
  49. data/spec/api/search/faceting_spec.rb +55 -52
  50. data/spec/api/search/highlighting_spec.rb +7 -7
  51. data/spec/api/search/hits_spec.rb +29 -29
  52. data/spec/api/search/paginated_collection_spec.rb +18 -18
  53. data/spec/api/search/results_spec.rb +13 -13
  54. data/spec/api/search/search_spec.rb +3 -3
  55. data/spec/api/search/stats_spec.rb +10 -10
  56. data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +19 -18
  57. data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +9 -9
  58. data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
  59. data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +10 -10
  60. data/spec/api/session_proxy/sharding_session_proxy_spec.rb +14 -13
  61. data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +2 -2
  62. data/spec/api/session_proxy/spec_helper.rb +1 -1
  63. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +9 -5
  64. data/spec/api/session_spec.rb +42 -42
  65. data/spec/api/sunspot_spec.rb +4 -4
  66. data/spec/integration/atomic_updates_spec.rb +25 -11
  67. data/spec/integration/dynamic_fields_spec.rb +10 -10
  68. data/spec/integration/faceting_spec.rb +39 -39
  69. data/spec/integration/field_grouping_spec.rb +16 -16
  70. data/spec/integration/field_lists_spec.rb +41 -0
  71. data/spec/integration/geospatial_spec.rb +19 -8
  72. data/spec/integration/highlighting_spec.rb +5 -5
  73. data/spec/integration/indexing_spec.rb +5 -5
  74. data/spec/integration/keyword_search_spec.rb +47 -45
  75. data/spec/integration/local_search_spec.rb +4 -4
  76. data/spec/integration/more_like_this_spec.rb +7 -7
  77. data/spec/integration/scoped_search_spec.rb +107 -107
  78. data/spec/integration/spellcheck_spec.rb +52 -7
  79. data/spec/integration/stats_spec.rb +10 -10
  80. data/spec/integration/stored_fields_spec.rb +1 -1
  81. data/spec/integration/test_pagination.rb +4 -4
  82. data/spec/integration/unicode_spec.rb +1 -1
  83. data/spec/mocks/post.rb +5 -1
  84. data/spec/spec_helper.rb +11 -6
  85. data/sunspot.gemspec +3 -1
  86. metadata +40 -7
@@ -3,28 +3,28 @@ shared_examples_for 'fulltext query' do
3
3
  search do
4
4
  keywords 'keyword search'
5
5
  end
6
- connection.should have_last_search_with(:q => 'keyword search')
6
+ expect(connection).to have_last_search_with(:q => 'keyword search')
7
7
  end
8
8
 
9
9
  it 'ignores keywords if empty' do
10
10
  search do
11
11
  keywords ''
12
12
  end
13
- connection.should_not have_last_search_with(:defType => 'edismax')
13
+ expect(connection).not_to have_last_search_with(:defType => 'edismax')
14
14
  end
15
15
 
16
16
  it 'ignores keywords if nil' do
17
17
  search do
18
18
  keywords nil
19
19
  end
20
- connection.should_not have_last_search_with(:defType => 'edismax')
20
+ expect(connection).not_to have_last_search_with(:defType => 'edismax')
21
21
  end
22
22
 
23
23
  it 'ignores keywords with only whitespace' do
24
24
  search do
25
25
  keywords " \t"
26
26
  end
27
- connection.should_not have_last_search_with(:defType => 'edismax')
27
+ expect(connection).not_to have_last_search_with(:defType => 'edismax')
28
28
  end
29
29
 
30
30
  it 'gracefully ignores keywords block if keywords ignored' do
@@ -37,14 +37,14 @@ shared_examples_for 'fulltext query' do
37
37
  search do
38
38
  keywords 'keyword search'
39
39
  end
40
- connection.should have_last_search_with(:defType => 'edismax')
40
+ expect(connection).to have_last_search_with(:defType => 'edismax')
41
41
  end
42
42
 
43
43
  it 'searches types in filter query if keywords used' do
44
44
  search do
45
45
  keywords 'keyword search'
46
46
  end
47
- connection.should have_last_search_with(:fq => ['type:Post'])
47
+ expect(connection).to have_last_search_with(:fq => ['type:Post'])
48
48
  end
49
49
 
50
50
  describe 'with multiple keyword components' do
@@ -56,20 +56,21 @@ shared_examples_for 'fulltext query' do
56
56
  end
57
57
 
58
58
  it 'puts specified keywords in subquery' do
59
- subqueries(:q).map { |subquery| subquery[:v] }.should ==
59
+ expect(subqueries(:q).map { |subquery| subquery[:v] }).to eq(
60
60
  ['first search', 'second search']
61
+ )
61
62
  end
62
63
 
63
64
  it 'puts specified dismax parameters in subquery' do
64
- subqueries(:q).first[:qf].should == 'title_text'
65
+ expect(subqueries(:q).first[:qf]).to eq('title_text')
65
66
  end
66
67
 
67
68
  it 'puts default dismax parameters in subquery' do
68
- subqueries(:q).last[:qf].split(' ').sort.should == %w(backwards_title_text body_textsv tags_textv title_text)
69
+ expect(subqueries(:q).last[:qf].split(' ').sort).to eq(%w(backwards_title_text body_textsv tags_textv title_text))
69
70
  end
70
71
 
71
72
  it 'puts field list in main query' do
72
- connection.should have_last_search_with(:fl => '* score')
73
+ expect(connection).to have_last_search_with(:fl => '* score')
73
74
  end
74
75
  end
75
76
 
@@ -77,21 +78,21 @@ shared_examples_for 'fulltext query' do
77
78
  search = search do
78
79
  keywords 'keyword search'
79
80
  end
80
- connection.searches.last[:qf].split(' ').sort.should == %w(backwards_title_text body_textsv tags_textv title_text)
81
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(backwards_title_text body_textsv tags_textv title_text))
81
82
  end
82
83
 
83
84
  it 'searches both stored and unstored text fields' do
84
85
  search Post, Namespaced::Comment do
85
86
  keywords 'keyword search'
86
87
  end
87
- connection.searches.last[:qf].split(' ').sort.should == %w(author_name_text backwards_title_text body_text body_textsv tags_textv title_text)
88
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(author_name_text backwards_title_text body_text body_textsv tags_textv title_text))
88
89
  end
89
90
 
90
91
  it 'searches only specified text fields when specified' do
91
92
  search do
92
93
  keywords 'keyword search', :fields => [:title, :body]
93
94
  end
94
- connection.searches.last[:qf].split(' ').sort.should == %w(body_textsv title_text)
95
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(body_textsv title_text))
95
96
  end
96
97
 
97
98
  it 'excludes text fields when instructed' do
@@ -100,7 +101,7 @@ shared_examples_for 'fulltext query' do
100
101
  exclude_fields :backwards_title, :body_mlt
101
102
  end
102
103
  end
103
- connection.searches.last[:qf].split(' ').sort.should == %w(body_textsv tags_textv title_text)
104
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(body_textsv tags_textv title_text))
104
105
  end
105
106
 
106
107
  it 'assigns boost to fields when specified' do
@@ -109,7 +110,7 @@ shared_examples_for 'fulltext query' do
109
110
  fields :title => 2.0, :body => 0.75
110
111
  end
111
112
  end
112
- connection.searches.last[:qf].split(' ').sort.should == %w(body_textsv^0.75 title_text^2.0)
113
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(body_textsv^0.75 title_text^2.0))
113
114
  end
114
115
 
115
116
  it 'allows assignment of boosted and unboosted fields' do
@@ -124,19 +125,19 @@ shared_examples_for 'fulltext query' do
124
125
  search Post, Namespaced::Comment do
125
126
  keywords 'keyword search', :fields => [:body]
126
127
  end
127
- connection.searches.last[:qf].split(' ').sort.should == %w(body_text body_textsv)
128
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(body_text body_textsv))
128
129
  end
129
130
 
130
131
  it 'requests score when keywords used' do
131
132
  search do
132
133
  keywords 'keyword search'
133
134
  end
134
- connection.should have_last_search_with(:fl => '* score')
135
+ expect(connection).to have_last_search_with(:fl => '* score')
135
136
  end
136
137
 
137
138
  it 'does not request score when keywords not used' do
138
139
  search Post
139
- connection.should_not have_last_search_with(:fl)
140
+ expect(connection).not_to have_last_search_with(:fl)
140
141
  end
141
142
 
142
143
  it 'sets phrase fields' do
@@ -145,7 +146,7 @@ shared_examples_for 'fulltext query' do
145
146
  phrase_fields :title => 2.0
146
147
  end
147
148
  end
148
- connection.should have_last_search_with(:pf => 'title_text^2.0')
149
+ expect(connection).to have_last_search_with(:pf => 'title_text^2.0')
149
150
  end
150
151
 
151
152
  it 'sets phrase fields with boost' do
@@ -154,7 +155,7 @@ shared_examples_for 'fulltext query' do
154
155
  phrase_fields :title => 1.5
155
156
  end
156
157
  end
157
- connection.should have_last_search_with(:pf => 'title_text^1.5')
158
+ expect(connection).to have_last_search_with(:pf => 'title_text^1.5')
158
159
  end
159
160
 
160
161
  it 'sets phrase slop from DSL' do
@@ -163,7 +164,7 @@ shared_examples_for 'fulltext query' do
163
164
  phrase_slop 2
164
165
  end
165
166
  end
166
- connection.should have_last_search_with(:ps => 2)
167
+ expect(connection).to have_last_search_with(:ps => 2)
167
168
  end
168
169
 
169
170
  it 'sets boost for certain fields without restricting fields' do
@@ -172,7 +173,7 @@ shared_examples_for 'fulltext query' do
172
173
  boost_fields :title => 1.5
173
174
  end
174
175
  end
175
- connection.searches.last[:qf].split(' ').sort.should == %w(backwards_title_text body_textsv tags_textv title_text^1.5)
176
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(backwards_title_text body_textsv tags_textv title_text^1.5))
176
177
  end
177
178
 
178
179
  it 'ignores boost fields that do not apply' do
@@ -181,7 +182,7 @@ shared_examples_for 'fulltext query' do
181
182
  boost_fields :bogus => 1.2, :title => 1.5
182
183
  end
183
184
  end
184
- connection.searches.last[:qf].split(' ').sort.should == %w(backwards_title_text body_textsv tags_textv title_text^1.5)
185
+ expect(connection.searches.last[:qf].split(' ').sort).to eq(%w(backwards_title_text body_textsv tags_textv title_text^1.5))
185
186
  end
186
187
 
187
188
  it 'sets default boost with default fields' do
@@ -189,14 +190,14 @@ shared_examples_for 'fulltext query' do
189
190
  keywords 'great pizza'
190
191
  end
191
192
  # Hashes in 1.8 aren't ordered
192
- connection.searches.last[:qf].split(" ").sort.join(" ").should eq 'caption_text^1.5 description_text'
193
+ expect(connection.searches.last[:qf].split(" ").sort.join(" ")).to eq 'caption_text^1.5 description_text'
193
194
  end
194
195
 
195
196
  it 'sets default boost with fields specified in options' do
196
197
  search Photo do
197
198
  keywords 'great pizza', :fields => [:caption]
198
199
  end
199
- connection.should have_last_search_with(:qf => 'caption_text^1.5')
200
+ expect(connection).to have_last_search_with(:qf => 'caption_text^1.5')
200
201
  end
201
202
 
202
203
  it 'sets default boost with fields specified in DSL' do
@@ -205,7 +206,7 @@ shared_examples_for 'fulltext query' do
205
206
  fields :caption
206
207
  end
207
208
  end
208
- connection.should have_last_search_with(:qf => 'caption_text^1.5')
209
+ expect(connection).to have_last_search_with(:qf => 'caption_text^1.5')
209
210
  end
210
211
 
211
212
  it 'overrides default boost when specified in DSL' do
@@ -214,7 +215,7 @@ shared_examples_for 'fulltext query' do
214
215
  fields :caption => 2.0
215
216
  end
216
217
  end
217
- connection.should have_last_search_with(:qf => 'caption_text^2.0')
218
+ expect(connection).to have_last_search_with(:qf => 'caption_text^2.0')
218
219
  end
219
220
 
220
221
  it 'creates boost query' do
@@ -225,7 +226,7 @@ shared_examples_for 'fulltext query' do
225
226
  end
226
227
  end
227
228
  end
228
- connection.should have_last_search_with(:bq => ['average_rating_ft:{2\.0 TO *}^2.0'])
229
+ expect(connection).to have_last_search_with(:bq => ['average_rating_ft:{2\.0 TO *}^2.0'])
229
230
  end
230
231
 
231
232
  it 'creates multiple boost queries' do
@@ -239,7 +240,7 @@ shared_examples_for 'fulltext query' do
239
240
  end
240
241
  end
241
242
  end
242
- connection.should have_last_search_with(
243
+ expect(connection).to have_last_search_with(
243
244
  :bq => [
244
245
  'average_rating_ft:{2\.0 TO *}^2.0',
245
246
  'featured_bs:true^1.5'
@@ -251,65 +252,65 @@ shared_examples_for 'fulltext query' do
251
252
  search do
252
253
  keywords 'great pizza', :minimum_match => 2
253
254
  end
254
- connection.should have_last_search_with(:mm => 2)
255
+ expect(connection).to have_last_search_with(:mm => 2)
255
256
  end
256
257
 
257
258
  it 'sends minimum match parameter from DSL' do
258
259
  search do
259
260
  keywords('great pizza') { minimum_match(2) }
260
261
  end
261
- connection.should have_last_search_with(:mm => 2)
262
+ expect(connection).to have_last_search_with(:mm => 2)
262
263
  end
263
264
 
264
265
  it 'sends tiebreaker parameter from options' do
265
266
  search do
266
267
  keywords 'great pizza', :tie => 0.1
267
268
  end
268
- connection.should have_last_search_with(:tie => 0.1)
269
+ expect(connection).to have_last_search_with(:tie => 0.1)
269
270
  end
270
271
 
271
272
  it 'sends tiebreaker parameter from DSL' do
272
273
  search do
273
274
  keywords('great pizza') { tie(0.1) }
274
275
  end
275
- connection.should have_last_search_with(:tie => 0.1)
276
+ expect(connection).to have_last_search_with(:tie => 0.1)
276
277
  end
277
278
 
278
279
  it 'sends query phrase slop from options' do
279
280
  search do
280
281
  keywords 'great pizza', :query_phrase_slop => 2
281
282
  end
282
- connection.should have_last_search_with(:qs => 2)
283
+ expect(connection).to have_last_search_with(:qs => 2)
283
284
  end
284
285
 
285
286
  it 'sends query phrase slop from DSL' do
286
287
  search do
287
288
  keywords('great pizza') { query_phrase_slop(2) }
288
289
  end
289
- connection.should have_last_search_with(:qs => 2)
290
+ expect(connection).to have_last_search_with(:qs => 2)
290
291
  end
291
292
 
292
293
  it 'allows specification of a text field that only exists in one type' do
293
294
  search Post, Namespaced::Comment do
294
295
  keywords 'keywords', :fields => :author_name
295
296
  end
296
- connection.searches.last[:qf].should == 'author_name_text'
297
+ expect(connection.searches.last[:qf]).to eq('author_name_text')
297
298
  end
298
299
 
299
300
  it 'raises Sunspot::UnrecognizedFieldError for nonexistant fields in keywords' do
300
- lambda do
301
+ expect do
301
302
  search do
302
303
  keywords :text, :fields => :bogus
303
304
  end
304
- end.should raise_error(Sunspot::UnrecognizedFieldError)
305
+ end.to raise_error(Sunspot::UnrecognizedFieldError)
305
306
  end
306
307
 
307
308
  it 'raises Sunspot::UnrecognizedFieldError if a text field that does not exist for any type is specified' do
308
- lambda do
309
+ expect do
309
310
  search Post, Namespaced::Comment do
310
311
  keywords 'fulltext', :fields => :bogus
311
312
  end
312
- end.should raise_error(Sunspot::UnrecognizedFieldError)
313
+ end.to raise_error(Sunspot::UnrecognizedFieldError)
313
314
  end
314
315
 
315
316
  describe 'connective examples' do
@@ -321,7 +322,7 @@ shared_examples_for 'fulltext query' do
321
322
  end
322
323
  end
323
324
 
324
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='title_text'}keywords1\" OR _query_:\"{!edismax qf='body_textsv'}keyword2\")"
325
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='title_text'}keywords1\" OR _query_:\"{!edismax qf='body_textsv'}keyword2\")"
325
326
  end
326
327
 
327
328
  it 'creates a conjunction inside of a disjunction' do
@@ -336,7 +337,7 @@ shared_examples_for 'fulltext query' do
336
337
  end
337
338
  end
338
339
 
339
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='body_textsv'}keywords1\" OR (_query_:\"{!edismax qf='body_textsv'}keyword2\" AND _query_:\"{!edismax qf='body_textsv'}keyword3\"))"
340
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='body_textsv'}keywords1\" OR (_query_:\"{!edismax qf='body_textsv'}keyword2\" AND _query_:\"{!edismax qf='body_textsv'}keyword3\"))"
340
341
  end
341
342
 
342
343
  it 'does nothing special if #all/#any called from the top level or called multiple times' do
@@ -347,7 +348,7 @@ shared_examples_for 'fulltext query' do
347
348
  end
348
349
  end
349
350
 
350
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='title_text'}keywords1\" AND _query_:\"{!edismax qf='body_textsv'}keyword2\")"
351
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='title_text'}keywords1\" AND _query_:\"{!edismax qf='body_textsv'}keyword2\")"
351
352
  end
352
353
 
353
354
  it 'does nothing special if #all/#any are mixed and called multiple times' do
@@ -362,7 +363,7 @@ shared_examples_for 'fulltext query' do
362
363
  end
363
364
  end
364
365
 
365
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='title_text'}keywords1\" AND _query_:\"{!edismax qf='body_textsv'}keyword2\")"
366
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='title_text'}keywords1\" AND _query_:\"{!edismax qf='body_textsv'}keyword2\")"
366
367
 
367
368
  search Post do
368
369
  any do
@@ -375,7 +376,7 @@ shared_examples_for 'fulltext query' do
375
376
  end
376
377
  end
377
378
 
378
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='title_text'}keywords1\" OR _query_:\"{!edismax qf='body_textsv'}keyword2\")"
379
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='title_text'}keywords1\" OR _query_:\"{!edismax qf='body_textsv'}keyword2\")"
379
380
  end
380
381
 
381
382
  it "does not add empty parentheses" do
@@ -392,7 +393,7 @@ shared_examples_for 'fulltext query' do
392
393
  end
393
394
  end
394
395
 
395
- connection.searches.last[:q].should eq "_query_:\"{!edismax qf='title_text'}keywords1\""
396
+ expect(connection.searches.last[:q]).to eq "_query_:\"{!edismax qf='title_text'}keywords1\""
396
397
  end
397
398
  end
398
399
 
@@ -409,9 +410,9 @@ shared_examples_for 'fulltext query' do
409
410
  q_name = "qPhoto#{obj_id}"
410
411
  fq_name = "f#{q_name}"
411
412
 
412
- connection.searches.last[:q].should eq "(_query_:\"{!join from=photo_container_id_i to=id_i v=$#{q_name} fq=$#{fq_name}}\" OR _query_:\"{!edismax qf='description_text^1.2'}keyword2\")"
413
- connection.searches.last[q_name].should eq "_query_:\"{!edismax qf='caption_text'}keyword1\""
414
- connection.searches.last[fq_name].should eq "type:Photo"
413
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!join from=photo_container_id_i to=id_i v=$#{q_name} fq=$#{fq_name}}\" OR _query_:\"{!edismax qf='description_text^1.2'}keyword2\")"
414
+ expect(connection.searches.last[q_name]).to eq "_query_:\"{!edismax qf='caption_text'}keyword1\""
415
+ expect(connection.searches.last[fq_name]).to eq "type:Photo"
415
416
  end
416
417
 
417
418
  it "should be able to resolve name conflicts with the :prefix option" do
@@ -426,9 +427,9 @@ shared_examples_for 'fulltext query' do
426
427
  q_name = "qPhoto#{obj_id}"
427
428
  fq_name = "f#{q_name}"
428
429
 
429
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='description_text^1.2'}keyword1\" OR _query_:\"{!join from=photo_container_id_i to=id_i v=$#{q_name} fq=$#{fq_name}}\")"
430
- connection.searches.last[q_name].should eq "_query_:\"{!edismax qf='description_text'}keyword2\""
431
- connection.searches.last[fq_name].should eq "type:Photo"
430
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='description_text^1.2'}keyword1\" OR _query_:\"{!join from=photo_container_id_i to=id_i v=$#{q_name} fq=$#{fq_name}}\")"
431
+ expect(connection.searches.last[q_name]).to eq "_query_:\"{!edismax qf='description_text'}keyword2\""
432
+ expect(connection.searches.last[fq_name]).to eq "type:Photo"
432
433
  end
433
434
 
434
435
  it "should recognize fields when adding from DSL, e.g. when calling boost_fields" do
@@ -444,9 +445,9 @@ shared_examples_for 'fulltext query' do
444
445
  q_name = "qPhoto#{obj_id}"
445
446
  fq_name = "f#{q_name}"
446
447
 
447
- connection.searches.last[:q].should eq "(_query_:\"{!edismax qf='description_text^1.5'}keyword1\" OR _query_:\"{!join from=photo_container_id_i to=id_i v=$#{q_name} fq=$#{fq_name}}\")"
448
- connection.searches.last[q_name].should eq "_query_:\"{!edismax qf='description_text^1.3'}keyword1\""
449
- connection.searches.last[fq_name].should eq "type:Photo"
448
+ expect(connection.searches.last[:q]).to eq "(_query_:\"{!edismax qf='description_text^1.5'}keyword1\" OR _query_:\"{!join from=photo_container_id_i to=id_i v=$#{q_name} fq=$#{fq_name}}\")"
449
+ expect(connection.searches.last[q_name]).to eq "_query_:\"{!edismax qf='description_text^1.3'}keyword1\""
450
+ expect(connection.searches.last[fq_name]).to eq "type:Photo"
450
451
  end
451
452
 
452
453
  private
@@ -7,7 +7,7 @@ describe 'function query' do
7
7
  boost(function { :average_rating })
8
8
  end
9
9
  end
10
- connection.should have_last_search_including(:bf, 'average_rating_ft')
10
+ expect(connection).to have_last_search_including(:bf, 'average_rating_ft')
11
11
  end
12
12
 
13
13
  it "should send query to solr with boost function and boost amount" do
@@ -16,7 +16,7 @@ describe 'function query' do
16
16
  boost(function { :average_rating }^5)
17
17
  end
18
18
  end
19
- connection.should have_last_search_including(:bf, 'average_rating_ft^5')
19
+ expect(connection).to have_last_search_including(:bf, 'average_rating_ft^5')
20
20
  end
21
21
 
22
22
  it "should handle boost function with constant float" do
@@ -25,7 +25,7 @@ describe 'function query' do
25
25
  boost(function { 10.5 })
26
26
  end
27
27
  end
28
- connection.should have_last_search_including(:bf, '10.5')
28
+ expect(connection).to have_last_search_including(:bf, '10.5')
29
29
  end
30
30
 
31
31
  it "should handle boost function with constant float and boost amount" do
@@ -34,7 +34,7 @@ describe 'function query' do
34
34
  boost(function { 10.5 }^5)
35
35
  end
36
36
  end
37
- connection.should have_last_search_including(:bf, '10.5^5')
37
+ expect(connection).to have_last_search_including(:bf, '10.5^5')
38
38
  end
39
39
 
40
40
  it "should handle boost function with time literal" do
@@ -43,7 +43,7 @@ describe 'function query' do
43
43
  boost(function { Time.parse('2010-03-25 14:13:00 EDT') })
44
44
  end
45
45
  end
46
- connection.should have_last_search_including(:bf, '2010-03-25T18:13:00Z')
46
+ expect(connection).to have_last_search_including(:bf, '2010-03-25T18:13:00Z')
47
47
  end
48
48
 
49
49
  it "should handle arbitrary functions in a function query block" do
@@ -52,7 +52,7 @@ describe 'function query' do
52
52
  boost(function { product(:average_rating, 10) })
53
53
  end
54
54
  end
55
- connection.should have_last_search_including(:bf, 'product(average_rating_ft,10)')
55
+ expect(connection).to have_last_search_including(:bf, 'product(average_rating_ft,10)')
56
56
  end
57
57
 
58
58
  it "should handle the sub function in a function query block" do
@@ -61,7 +61,7 @@ describe 'function query' do
61
61
  boost(function { sub(:average_rating, 10) })
62
62
  end
63
63
  end
64
- connection.should have_last_search_including(:bf, 'sub(average_rating_ft,10)')
64
+ expect(connection).to have_last_search_including(:bf, 'sub(average_rating_ft,10)')
65
65
  end
66
66
 
67
67
  it "should handle boost amounts on function query block" do
@@ -70,7 +70,7 @@ describe 'function query' do
70
70
  boost(function { sub(:average_rating, 10)^5 })
71
71
  end
72
72
  end
73
- connection.should have_last_search_including(:bf, 'sub(average_rating_ft,10)^5')
73
+ expect(connection).to have_last_search_including(:bf, 'sub(average_rating_ft,10)^5')
74
74
  end
75
75
 
76
76
  it "should handle nested functions in a function query block" do
@@ -79,28 +79,28 @@ describe 'function query' do
79
79
  boost(function { product(:average_rating, sum(:average_rating, 20)) })
80
80
  end
81
81
  end
82
- connection.should have_last_search_including(:bf, 'product(average_rating_ft,sum(average_rating_ft,20))')
82
+ expect(connection).to have_last_search_including(:bf, 'product(average_rating_ft,sum(average_rating_ft,20))')
83
83
  end
84
84
 
85
85
  # TODO SOLR 1.5
86
86
  it "should raise ArgumentError if string literal passed" do
87
- lambda do
87
+ expect do
88
88
  session.search Post do
89
89
  keywords('pizza') do
90
90
  boost(function { "hello world" })
91
91
  end
92
92
  end
93
- end.should raise_error(ArgumentError)
93
+ end.to raise_error(ArgumentError)
94
94
  end
95
95
 
96
96
  it "should raise UnrecognizedFieldError if bogus field name passed" do
97
- lambda do
97
+ expect do
98
98
  session.search Post do
99
99
  keywords('pizza') do
100
100
  boost(function { :bogus })
101
101
  end
102
102
  end
103
- end.should raise_error(Sunspot::UnrecognizedFieldError)
103
+ end.to raise_error(Sunspot::UnrecognizedFieldError)
104
104
  end
105
105
 
106
106
  it "should send query to solr with multiplicative boost function" do
@@ -109,7 +109,7 @@ describe 'function query' do
109
109
  multiplicative_boost(function { :average_rating })
110
110
  end
111
111
  end
112
- connection.should have_last_search_including(:boost, 'average_rating_ft')
112
+ expect(connection).to have_last_search_including(:boost, 'average_rating_ft')
113
113
  end
114
114
 
115
115
  it "should send query to solr with multiplicative boost function and boost amount" do
@@ -118,7 +118,7 @@ describe 'function query' do
118
118
  multiplicative_boost(function { :average_rating }^5)
119
119
  end
120
120
  end
121
- connection.should have_last_search_including(:boost, 'average_rating_ft^5')
121
+ expect(connection).to have_last_search_including(:boost, 'average_rating_ft^5')
122
122
  end
123
123
 
124
124
  it "should handle multiplicative boost function with constant float" do
@@ -127,7 +127,7 @@ describe 'function query' do
127
127
  multiplicative_boost(function { 10.5 })
128
128
  end
129
129
  end
130
- connection.should have_last_search_including(:boost, '10.5')
130
+ expect(connection).to have_last_search_including(:boost, '10.5')
131
131
  end
132
132
 
133
133
  it "should handle multiplicative boost function with constant float and boost amount" do
@@ -136,7 +136,7 @@ describe 'function query' do
136
136
  multiplicative_boost(function { 10.5 }^5)
137
137
  end
138
138
  end
139
- connection.should have_last_search_including(:boost, '10.5^5')
139
+ expect(connection).to have_last_search_including(:boost, '10.5^5')
140
140
  end
141
141
 
142
142
  it "should handle multiplicative boost function with time literal" do
@@ -145,7 +145,7 @@ describe 'function query' do
145
145
  multiplicative_boost(function { Time.parse('2010-03-25 14:13:00 EDT') })
146
146
  end
147
147
  end
148
- connection.should have_last_search_including(:boost, '2010-03-25T18:13:00Z')
148
+ expect(connection).to have_last_search_including(:boost, '2010-03-25T18:13:00Z')
149
149
  end
150
150
 
151
151
  it "should handle arbitrary functions in a function query block" do
@@ -154,7 +154,7 @@ describe 'function query' do
154
154
  multiplicative_boost(function { product(:average_rating, 10) })
155
155
  end
156
156
  end
157
- connection.should have_last_search_including(:boost, 'product(average_rating_ft,10)')
157
+ expect(connection).to have_last_search_including(:boost, 'product(average_rating_ft,10)')
158
158
  end
159
159
 
160
160
  it "should handle the sub function in a multiplicative boost function query block" do
@@ -163,7 +163,7 @@ describe 'function query' do
163
163
  multiplicative_boost(function { sub(:average_rating, 10) })
164
164
  end
165
165
  end
166
- connection.should have_last_search_including(:boost, 'sub(average_rating_ft,10)')
166
+ expect(connection).to have_last_search_including(:boost, 'sub(average_rating_ft,10)')
167
167
  end
168
168
 
169
169
  it "should handle boost amounts on multiplicative boost function query block" do
@@ -172,7 +172,7 @@ describe 'function query' do
172
172
  multiplicative_boost(function { sub(:average_rating, 10)^5 })
173
173
  end
174
174
  end
175
- connection.should have_last_search_including(:boost, 'sub(average_rating_ft,10)^5')
175
+ expect(connection).to have_last_search_including(:boost, 'sub(average_rating_ft,10)^5')
176
176
  end
177
177
 
178
178
  it "should handle nested functions in a multiplicative boost function query block" do
@@ -181,28 +181,28 @@ describe 'function query' do
181
181
  multiplicative_boost(function { product(:average_rating, sum(:average_rating, 20)) })
182
182
  end
183
183
  end
184
- connection.should have_last_search_including(:boost, 'product(average_rating_ft,sum(average_rating_ft,20))')
184
+ expect(connection).to have_last_search_including(:boost, 'product(average_rating_ft,sum(average_rating_ft,20))')
185
185
  end
186
186
 
187
187
  # TODO SOLR 1.5
188
188
  it "should raise ArgumentError if string literal passed to multiplicative boost" do
189
- lambda do
189
+ expect do
190
190
  session.search Post do
191
191
  keywords('pizza') do
192
192
  multiplicative_boost(function { "hello world" })
193
193
  end
194
194
  end
195
- end.should raise_error(ArgumentError)
195
+ end.to raise_error(ArgumentError)
196
196
  end
197
197
 
198
198
  it "should raise UnrecognizedFieldError if bogus field name passed to multiplicative boost" do
199
- lambda do
199
+ expect do
200
200
  session.search Post do
201
201
  keywords('pizza') do
202
202
  multiplicative_boost(function { :bogus })
203
203
  end
204
204
  end
205
- end.should raise_error(Sunspot::UnrecognizedFieldError)
205
+ end.to raise_error(Sunspot::UnrecognizedFieldError)
206
206
  end
207
207
 
208
208
  end