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
@@ -7,8 +7,8 @@ describe Sunspot do
7
7
  Sunspot.setup(User) do
8
8
  text :name
9
9
  end
10
- Sunspot.searchable.should_not be_empty
11
- Sunspot.searchable.should include(User)
10
+ expect(Sunspot.searchable).not_to be_empty
11
+ expect(Sunspot.searchable).to include(User)
12
12
  end
13
13
  end
14
14
 
@@ -16,14 +16,14 @@ describe Sunspot do
16
16
  it "should reset current session" do
17
17
  old_session = Sunspot.send(:session)
18
18
  Sunspot.reset!(true)
19
- Sunspot.send(:session).should_not == old_session
19
+ expect(Sunspot.send(:session)).not_to eq(old_session)
20
20
  end
21
21
 
22
22
  it "should keep keep configuration if specified" do
23
23
  Sunspot.config.solr.url = "http://localhost:9999/path/solr"
24
24
  config_before_reset = Sunspot.config
25
25
  Sunspot.reset!(true)
26
- Sunspot.config.should == config_before_reset
26
+ expect(Sunspot.config).to eq(config_before_reset)
27
27
  end
28
28
  end
29
29
  end
@@ -5,14 +5,16 @@ describe 'atomic updates' do
5
5
  Sunspot.remove_all
6
6
  end
7
7
 
8
- def validate_hit(hit, title, featured)
9
- hit.stored(:title).should == title
10
- hit.stored(:featured).should == featured
8
+ def validate_hit(hit, values = {})
9
+ values.each do |field, value|
10
+ stored = hit.stored(field)
11
+ expect(stored).to eq(value), "expected #{value.inspect}, but got #{stored.inspect} for field '#{field}'"
12
+ end
11
13
  end
12
14
 
13
15
  def find_indexed_post(id)
14
16
  hit = Sunspot.search(Post).hits.find{ |h| h.primary_key.to_i == id }
15
- hit.should_not be_nil
17
+ expect(hit).not_to be_nil
16
18
  hit
17
19
  end
18
20
 
@@ -20,13 +22,13 @@ describe 'atomic updates' do
20
22
  post = Post.new(title: 'A Title', featured: true)
21
23
  Sunspot.index!(post)
22
24
 
23
- validate_hit(find_indexed_post(post.id), post.title, post.featured)
25
+ validate_hit(find_indexed_post(post.id), title: post.title, featured: post.featured)
24
26
 
25
27
  Sunspot.atomic_update!(Post, post.id => {title: 'A New Title'})
26
- validate_hit(find_indexed_post(post.id), 'A New Title', true)
28
+ validate_hit(find_indexed_post(post.id), title: 'A New Title', featured: true)
27
29
 
28
30
  Sunspot.atomic_update!(Post, post.id => {featured: false})
29
- validate_hit(find_indexed_post(post.id), 'A New Title', false)
31
+ validate_hit(find_indexed_post(post.id), title: 'A New Title', featured: false)
30
32
  end
31
33
 
32
34
  it 'should update fields for multiple records' do
@@ -34,11 +36,23 @@ describe 'atomic updates' do
34
36
  post2 = Post.new(title: 'A Second Title', featured: false)
35
37
  Sunspot.index!(post1, post2)
36
38
 
37
- validate_hit(find_indexed_post(post1.id), post1.title, post1.featured)
38
- validate_hit(find_indexed_post(post2.id), post2.title, post2.featured)
39
+ validate_hit(find_indexed_post(post1.id), title: post1.title, featured: post1.featured)
40
+ validate_hit(find_indexed_post(post2.id), title: post2.title, featured: post2.featured)
39
41
 
40
42
  Sunspot.atomic_update!(Post, post1.id => {title: 'A New Title'}, post2.id => {featured: true})
41
- validate_hit(find_indexed_post(post1.id), 'A New Title', true)
42
- validate_hit(find_indexed_post(post2.id), 'A Second Title', true)
43
+ validate_hit(find_indexed_post(post1.id), title: 'A New Title', featured: true)
44
+ validate_hit(find_indexed_post(post2.id), title: 'A Second Title', featured: true)
45
+ end
46
+
47
+ it 'should clear field value properly' do
48
+ post = Post.new(title: 'A Title', tags: %w(tag1 tag2), featured: true)
49
+ Sunspot.index!(post)
50
+ validate_hit(find_indexed_post(post.id), title: post.title, tag_list: post.tags, featured: true)
51
+
52
+ Sunspot.atomic_update!(Post, post.id => {tag_list: []})
53
+ validate_hit(find_indexed_post(post.id), title: post.title, tag_list: nil, featured: true)
54
+
55
+ Sunspot.atomic_update!(Post, post.id => {featured: nil})
56
+ validate_hit(find_indexed_post(post.id), title: post.title, tag_list: nil, featured: nil)
43
57
  end
44
58
  end
@@ -10,11 +10,11 @@ shared_examples 'dynamic fields' do
10
10
  end
11
11
 
12
12
  it 'should search for dynamic string field' do
13
- Sunspot.search(Post) do
13
+ expect(Sunspot.search(Post) do
14
14
  dynamic(field_name) do
15
15
  with(:cuisine, 'Pizza')
16
16
  end
17
- end.results.should == [@posts.first]
17
+ end.results).to eq([@posts.first])
18
18
  end
19
19
 
20
20
  describe 'faceting' do
@@ -28,31 +28,31 @@ shared_examples 'dynamic fields' do
28
28
 
29
29
  it 'should return value "value" with count 2' do
30
30
  row = @search.dynamic_facet(field_name, :cuisine).rows[0]
31
- row.value.should == 'Greek'
32
- row.count.should == 2
31
+ expect(row.value).to eq('Greek')
32
+ expect(row.count).to eq(2)
33
33
  end
34
34
 
35
35
  it 'should return value "other" with count 1' do
36
36
  row = @search.dynamic_facet(field_name, :cuisine).rows[1]
37
- row.value.should == 'Pizza'
38
- row.count.should == 1
37
+ expect(row.value).to eq('Pizza')
38
+ expect(row.count).to eq(1)
39
39
  end
40
40
  end
41
41
 
42
42
  it 'should order by dynamic string field ascending' do
43
- Sunspot.search(Post) do
43
+ expect(Sunspot.search(Post) do
44
44
  dynamic field_name do
45
45
  order_by :cuisine, :asc
46
46
  end
47
- end.results.last.should == @posts.first
47
+ end.results.last).to eq(@posts.first)
48
48
  end
49
49
 
50
50
  it 'should order by dynamic string field descending' do
51
- Sunspot.search(Post) do
51
+ expect(Sunspot.search(Post) do
52
52
  dynamic field_name do
53
53
  order_by :cuisine, :desc
54
54
  end
55
- end.results.first.should == @posts.first
55
+ end.results.first).to eq(@posts.first)
56
56
  end
57
57
  end
58
58
 
@@ -27,14 +27,14 @@ describe 'search faceting' do
27
27
 
28
28
  it "should return value #{value1.inspect} with count 2" do
29
29
  row = @search.facet(field).rows[0]
30
- row.value.should == value1
31
- row.count.should == 2
30
+ expect(row.value).to eq(value1)
31
+ expect(row.count).to eq(2)
32
32
  end
33
33
 
34
34
  it "should return value #{value2.inspect} with count 1" do
35
35
  row = @search.facet(field).rows[1]
36
- row.value.should == value2
37
- row.count.should == 1
36
+ expect(row.value).to eq(value2)
37
+ expect(row.count).to eq(1)
38
38
  end
39
39
  end
40
40
  end
@@ -66,7 +66,7 @@ describe 'search faceting' do
66
66
  search = Sunspot.search(Post) do
67
67
  facet :title, :limit => 3
68
68
  end
69
- search.facet(:title).should have(3).rows
69
+ expect(search.facet(:title).rows.size).to eq(3)
70
70
  end
71
71
 
72
72
  it 'should not return zeros by default' do
@@ -74,7 +74,7 @@ describe 'search faceting' do
74
74
  with :blog_id, 1
75
75
  facet :title
76
76
  end
77
- search.facet(:title).rows.map { |row| row.value }.should_not include('zero')
77
+ expect(search.facet(:title).rows.map { |row| row.value }).not_to include('zero')
78
78
  end
79
79
 
80
80
  it 'should return zeros when specified' do
@@ -82,14 +82,14 @@ describe 'search faceting' do
82
82
  with :blog_id, 1
83
83
  facet :title, :zeros => true
84
84
  end
85
- search.facet(:title).rows.map { |row| row.value }.should include('zero')
85
+ expect(search.facet(:title).rows.map { |row| row.value }).to include('zero')
86
86
  end
87
87
 
88
88
  it 'should return facet rows from an offset' do
89
89
  search = Sunspot.search(Post) do
90
90
  facet :title, :offset => 3
91
91
  end
92
- search.facet(:title).rows.map { |row| row.value }.should == %w(one zero)
92
+ expect(search.facet(:title).rows.map { |row| row.value }).to eq(%w(one zero))
93
93
  end
94
94
 
95
95
  it 'should return a specified minimum count' do
@@ -97,7 +97,7 @@ describe 'search faceting' do
97
97
  with :blog_id, 1
98
98
  facet :title, :minimum_count => 2
99
99
  end
100
- search.facet(:title).rows.map { |row| row.value }.should == %w(four three two)
100
+ expect(search.facet(:title).rows.map { |row| row.value }).to eq(%w(four three two))
101
101
  end
102
102
 
103
103
  it 'should order facets lexically' do
@@ -105,7 +105,7 @@ describe 'search faceting' do
105
105
  with :blog_id, 1
106
106
  facet :title, :sort => :index
107
107
  end
108
- search.facet(:title).rows.map { |row| row.value }.should == %w(four one three two)
108
+ expect(search.facet(:title).rows.map { |row| row.value }).to eq(%w(four one three two))
109
109
  end
110
110
 
111
111
  it 'should order facets by count' do
@@ -113,7 +113,7 @@ describe 'search faceting' do
113
113
  with :blog_id, 1
114
114
  facet :title, :sort => :count
115
115
  end
116
- search.facet(:title).rows.map { |row| row.value }.should == %w(four three two one)
116
+ expect(search.facet(:title).rows.map { |row| row.value }).to eq(%w(four three two one))
117
117
  end
118
118
 
119
119
  it 'should limit facet values by prefix' do
@@ -121,7 +121,7 @@ describe 'search faceting' do
121
121
  with :blog_id, 1
122
122
  facet :title, :prefix => 't'
123
123
  end
124
- search.facet(:title).rows.map { |row| row.value }.sort.should == %w(three two)
124
+ expect(search.facet(:title).rows.map { |row| row.value }.sort).to eq(%w(three two))
125
125
  end
126
126
 
127
127
  it 'should return :all facet' do
@@ -129,8 +129,8 @@ describe 'search faceting' do
129
129
  with :blog_id, 1
130
130
  facet :title, :extra => :any
131
131
  end
132
- search.facet(:title).rows.first.value.should == :any
133
- search.facet(:title).rows.first.count.should == 10
132
+ expect(search.facet(:title).rows.first.value).to eq(:any)
133
+ expect(search.facet(:title).rows.first.count).to eq(10)
134
134
  end
135
135
 
136
136
  it 'should return :none facet' do
@@ -138,8 +138,8 @@ describe 'search faceting' do
138
138
  with :blog_id, 1
139
139
  facet :title, :extra => :none
140
140
  end
141
- search.facet(:title).rows.first.value.should == :none
142
- search.facet(:title).rows.first.count.should == 1
141
+ expect(search.facet(:title).rows.first.value).to eq(:none)
142
+ expect(search.facet(:title).rows.first.count).to eq(1)
143
143
  end
144
144
 
145
145
  it 'gives correct facet count when group == true and truncate == true' do
@@ -152,7 +152,7 @@ describe 'search faceting' do
152
152
  end
153
153
 
154
154
  # Should be 5 instead of 11
155
- search.facet(:title).rows.first.count.should == 5
155
+ expect(search.facet(:title).rows.first.count).to eq(5)
156
156
  end
157
157
  end
158
158
 
@@ -170,7 +170,7 @@ describe 'search faceting' do
170
170
  with :blog_id, 1
171
171
  facet :title, :prefix => 'title '
172
172
  end
173
- search.facet(:title).rows.map { |row| row.value }.sort.should == ["title with spaces 1", "title with spaces 2"]
173
+ expect(search.facet(:title).rows.map { |row| row.value }.sort).to eq(["title with spaces 1", "title with spaces 2"])
174
174
  end
175
175
 
176
176
  it 'should limit facet values by a prefix with slashes' do
@@ -178,7 +178,7 @@ describe 'search faceting' do
178
178
  with :blog_id, 1
179
179
  facet :title, :prefix => 'title/'
180
180
  end
181
- search.facet(:title).rows.map { |row| row.value }.sort.should == ["title/with/slashes/1", "title/with/slashes/2"]
181
+ expect(search.facet(:title).rows.map { |row| row.value }.sort).to eq(["title/with/slashes/1", "title/with/slashes/2"])
182
182
  end
183
183
  end
184
184
 
@@ -199,7 +199,7 @@ describe 'search faceting' do
199
199
  category_filter = with(:category_ids, 1)
200
200
  facet(:category_ids, :exclude => category_filter)
201
201
  end
202
- search.facet(:category_ids).rows.map { |row| row.value }.to_set.should == Set[1, 2]
202
+ expect(search.facet(:category_ids).rows.map { |row| row.value }.to_set).to eq(Set[1, 2])
203
203
  end
204
204
 
205
205
  it 'should use facet keys to facet more than once with different exclusions' do
@@ -209,8 +209,8 @@ describe 'search faceting' do
209
209
  facet(:category_ids)
210
210
  facet(:category_ids, :exclude => category_filter, :name => :all_category_ids)
211
211
  end
212
- search.facet(:category_ids).rows.map { |row| row.value }.should == [1]
213
- search.facet(:all_category_ids).rows.map { |row| row.value }.to_set.should == Set[1, 2]
212
+ expect(search.facet(:category_ids).rows.map { |row| row.value }).to eq([1])
213
+ expect(search.facet(:all_category_ids).rows.map { |row| row.value }.to_set).to eq(Set[1, 2])
214
214
  end
215
215
  end
216
216
 
@@ -228,7 +228,7 @@ describe 'search faceting' do
228
228
  end
229
229
  end
230
230
  end
231
- search.facet(:category_ids).rows.map { |row| [row.value, row.count] }.to_set.should == Set[[:category_1, 1], [:category_2, 1]]
231
+ expect(search.facet(:category_ids).rows.map { |row| [row.value, row.count] }.to_set).to eq(Set[[:category_1, 1], [:category_2, 1]])
232
232
  end
233
233
 
234
234
  it 'should use facet keys to facet more than once with different exclusions' do
@@ -253,8 +253,8 @@ describe 'search faceting' do
253
253
  end
254
254
  end
255
255
  end
256
- search.facet(:category_ids).rows.map { |row| [row.value, row.count] }.to_set.should == Set[[:category_1, 1]]
257
- search.facet(:all_category_ids).rows.map { |row| [row.value, row.count] }.to_set.should == Set[[:category_1, 1], [:category_2, 1]]
256
+ expect(search.facet(:category_ids).rows.map { |row| [row.value, row.count] }.to_set).to eq(Set[[:category_1, 1]])
257
+ expect(search.facet(:all_category_ids).rows.map { |row| [row.value, row.count] }.to_set).to eq(Set[[:category_1, 1], [:category_2, 1]])
258
258
  end
259
259
  end
260
260
  end
@@ -273,10 +273,10 @@ describe 'search faceting' do
273
273
  search = Sunspot.search(Post) do
274
274
  facet :published_at, :time_range => time..(time + 60*60*24*2), :sort => :count
275
275
  end
276
- search.facet(:published_at).rows.first.value.should == (time..(time + 60*60*24))
277
- search.facet(:published_at).rows.first.count.should == 2
278
- search.facet(:published_at).rows.last.value.should == ((time + 60*60*24)..(time + 60*60*24*2))
279
- search.facet(:published_at).rows.last.count.should == 1
276
+ expect(search.facet(:published_at).rows.first.value).to eq(time..(time + 60*60*24))
277
+ expect(search.facet(:published_at).rows.first.count).to eq(2)
278
+ expect(search.facet(:published_at).rows.last.value).to eq((time + 60*60*24)..(time + 60*60*24*2))
279
+ expect(search.facet(:published_at).rows.last.count).to eq(1)
280
280
  end
281
281
  end
282
282
 
@@ -290,10 +290,10 @@ describe 'search faceting' do
290
290
  search = Sunspot.search(Post, Namespaced::Comment) do
291
291
  facet(:class, :sort => :count)
292
292
  end
293
- search.facet(:class).rows.first.value.should == Post
294
- search.facet(:class).rows.first.count.should == 2
295
- search.facet(:class).rows.last.value.should == Namespaced::Comment
296
- search.facet(:class).rows.last.count.should == 1
293
+ expect(search.facet(:class).rows.first.value).to eq(Post)
294
+ expect(search.facet(:class).rows.first.count).to eq(2)
295
+ expect(search.facet(:class).rows.last.value).to eq(Namespaced::Comment)
296
+ expect(search.facet(:class).rows.last.count).to eq(1)
297
297
  end
298
298
  end
299
299
 
@@ -319,12 +319,12 @@ describe 'search faceting' do
319
319
  end
320
320
  end
321
321
  facet = search.facet(:rating_range)
322
- facet.rows[0].value.should == (3.0..4.0)
323
- facet.rows[0].count.should == 3
324
- facet.rows[1].value.should == (1.0..2.0)
325
- facet.rows[1].count.should == 2
326
- facet.rows[2].value.should == (4.0..5.0)
327
- facet.rows[2].count.should == 1
322
+ expect(facet.rows[0].value).to eq(3.0..4.0)
323
+ expect(facet.rows[0].count).to eq(3)
324
+ expect(facet.rows[1].value).to eq(1.0..2.0)
325
+ expect(facet.rows[1].count).to eq(2)
326
+ expect(facet.rows[2].value).to eq(4.0..5.0)
327
+ expect(facet.rows[2].count).to eq(1)
328
328
  end
329
329
  end
330
330
  end
@@ -19,8 +19,8 @@ describe "field grouping" do
19
19
  group :title
20
20
  end
21
21
 
22
- search.group(:title).groups.should include { |g| g.value == "Title1" }
23
- search.group(:title).groups.should include { |g| g.value == "Title2" }
22
+ expect(search.group(:title).groups).to include { |g| g.value == "Title1" }
23
+ expect(search.group(:title).groups).to include { |g| g.value == "Title2" }
24
24
  end
25
25
 
26
26
  it "returns the number of matches unique groups" do
@@ -28,7 +28,7 @@ describe "field grouping" do
28
28
  group :title
29
29
  end
30
30
 
31
- search.group(:title).total.should == 2
31
+ expect(search.group(:title).total).to eq(2)
32
32
  end
33
33
 
34
34
  it "provides access to the number of matches before grouping" do
@@ -36,7 +36,7 @@ describe "field grouping" do
36
36
  group :title
37
37
  end
38
38
 
39
- search.group(:title).matches.should == @posts.length
39
+ expect(search.group(:title).matches).to eq(@posts.length)
40
40
  end
41
41
 
42
42
  it "allows grouping by multiple fields" do
@@ -44,8 +44,8 @@ describe "field grouping" do
44
44
  group :title, :sort_title
45
45
  end
46
46
 
47
- search.group(:title).groups.should_not be_empty
48
- search.group(:sort_title).groups.should_not be_empty
47
+ expect(search.group(:title).groups).not_to be_empty
48
+ expect(search.group(:sort_title).groups).not_to be_empty
49
49
  end
50
50
 
51
51
  it "allows specification of the number of documents per group" do
@@ -56,7 +56,7 @@ describe "field grouping" do
56
56
  end
57
57
 
58
58
  title1_group = search.group(:title).groups.detect { |g| g.value == "Title1" }
59
- title1_group.hits.length.should == 2
59
+ expect(title1_group.hits.length).to eq(2)
60
60
  end
61
61
 
62
62
  it "allows specification of the sort within groups" do
@@ -69,7 +69,7 @@ describe "field grouping" do
69
69
  highest_ranked_post = @posts.sort_by { |p| -p.ratings_average }.first
70
70
 
71
71
  title1_group = search.group(:title).groups.detect { |g| g.value == "Title1" }
72
- title1_group.hits.first.primary_key.to_i.should == highest_ranked_post.id
72
+ expect(title1_group.hits.first.primary_key.to_i).to eq(highest_ranked_post.id)
73
73
  end
74
74
 
75
75
  it "allows specification of an ordering function within groups" do
@@ -82,7 +82,7 @@ describe "field grouping" do
82
82
  highest_ranked_post = @posts.sort_by { |p| -p.ratings_average }.first
83
83
 
84
84
  title1_group = search.group(:title).groups.detect { |g| g.value == "Title1" }
85
- title1_group.hits.first.primary_key.to_i.should == highest_ranked_post.id
85
+ expect(title1_group.hits.first.primary_key.to_i).to eq(highest_ranked_post.id)
86
86
  end
87
87
 
88
88
  it "allows pagination within groups" do
@@ -91,8 +91,8 @@ describe "field grouping" do
91
91
  paginate :per_page => 1, :page => 2
92
92
  end
93
93
 
94
- search.group(:title).groups.length.should eql(1)
95
- search.group(:title).groups.first.results.should == [ @posts.last ]
94
+ expect(search.group(:title).groups.length).to eql(1)
95
+ expect(search.group(:title).groups.first.results).to eq([ @posts.last ])
96
96
  end
97
97
 
98
98
  context "returns a paginated collection" do
@@ -104,10 +104,10 @@ describe "field grouping" do
104
104
  search.group(:title).groups
105
105
  end
106
106
 
107
- it { subject.per_page.should eql(1) }
108
- it { subject.total_pages.should eql(2) }
109
- it { subject.current_page.should eql(2) }
110
- it { subject.first_page?.should be_false }
111
- it { subject.last_page?.should be_true }
107
+ it { expect(subject.per_page).to eql(1) }
108
+ it { expect(subject.total_pages).to eql(2) }
109
+ it { expect(subject.current_page).to eql(2) }
110
+ it { expect(subject.first_page?).to be(false) }
111
+ it { expect(subject.last_page?).to be(true) }
112
112
  end
113
113
  end