sunspot 2.2.7 → 2.5.0

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.
Files changed (117) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/Appraisals +7 -0
  5. data/Gemfile +0 -8
  6. data/lib/sunspot/adapters.rb +4 -1
  7. data/lib/sunspot/configuration.rb +1 -0
  8. data/lib/sunspot/data_extractor.rb +36 -6
  9. data/lib/sunspot/dsl/field_query.rb +11 -0
  10. data/lib/sunspot/dsl/field_stats.rb +7 -0
  11. data/lib/sunspot/dsl/fields.rb +16 -0
  12. data/lib/sunspot/dsl/group.rb +10 -0
  13. data/lib/sunspot/dsl/scope.rb +23 -18
  14. data/lib/sunspot/field.rb +11 -0
  15. data/lib/sunspot/field_factory.rb +6 -2
  16. data/lib/sunspot/query/abstract_json_field_facet.rb +70 -0
  17. data/lib/sunspot/query/bbox.rb +5 -1
  18. data/lib/sunspot/query/date_field_json_facet.rb +25 -0
  19. data/lib/sunspot/query/field_json_facet.rb +19 -0
  20. data/lib/sunspot/query/field_stats.rb +35 -2
  21. data/lib/sunspot/query/group.rb +4 -5
  22. data/lib/sunspot/query/join.rb +2 -4
  23. data/lib/sunspot/query/range_json_facet.rb +28 -0
  24. data/lib/sunspot/query/restriction.rb +19 -4
  25. data/lib/sunspot/query.rb +3 -3
  26. data/lib/sunspot/schema.rb +10 -2
  27. data/lib/sunspot/search/abstract_search.rb +14 -1
  28. data/lib/sunspot/search/field_json_facet.rb +33 -0
  29. data/lib/sunspot/search/hit.rb +6 -1
  30. data/lib/sunspot/search/hit_enumerable.rb +4 -1
  31. data/lib/sunspot/search/json_facet_row.rb +40 -0
  32. data/lib/sunspot/search/json_facet_stats.rb +23 -0
  33. data/lib/sunspot/search/standard_search.rb +2 -3
  34. data/lib/sunspot/search/stats_json_row.rb +82 -0
  35. data/lib/sunspot/search/stats_row.rb +3 -1
  36. data/lib/sunspot/search.rb +4 -3
  37. data/lib/sunspot/session.rb +13 -5
  38. data/lib/sunspot/setup.rb +31 -0
  39. data/lib/sunspot/util.rb +23 -0
  40. data/lib/sunspot/version.rb +1 -1
  41. data/spec/api/adapters_spec.rb +32 -19
  42. data/spec/api/batcher_spec.rb +15 -15
  43. data/spec/api/binding_spec.rb +3 -3
  44. data/spec/api/class_set_spec.rb +3 -3
  45. data/spec/api/data_extractor_spec.rb +39 -0
  46. data/spec/api/hit_enumerable_spec.rb +32 -9
  47. data/spec/api/indexer/attributes_spec.rb +31 -31
  48. data/spec/api/indexer/batch_spec.rb +8 -7
  49. data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
  50. data/spec/api/indexer/fixed_fields_spec.rb +12 -12
  51. data/spec/api/indexer/fulltext_spec.rb +8 -8
  52. data/spec/api/indexer/removal_spec.rb +14 -14
  53. data/spec/api/indexer_spec.rb +2 -2
  54. data/spec/api/query/advanced_manipulation_examples.rb +3 -3
  55. data/spec/api/query/connectives_examples.rb +26 -14
  56. data/spec/api/query/dsl_spec.rb +17 -9
  57. data/spec/api/query/dynamic_fields_examples.rb +18 -18
  58. data/spec/api/query/faceting_examples.rb +62 -62
  59. data/spec/api/query/fulltext_examples.rb +63 -58
  60. data/spec/api/query/function_spec.rb +26 -26
  61. data/spec/api/query/geo_examples.rb +6 -6
  62. data/spec/api/query/group_spec.rb +6 -6
  63. data/spec/api/query/highlighting_examples.rb +26 -26
  64. data/spec/api/query/join_spec.rb +2 -2
  65. data/spec/api/query/more_like_this_spec.rb +29 -29
  66. data/spec/api/query/ordering_pagination_examples.rb +25 -25
  67. data/spec/api/query/scope_examples.rb +39 -39
  68. data/spec/api/query/spatial_examples.rb +3 -3
  69. data/spec/api/query/spellcheck_examples.rb +3 -3
  70. data/spec/api/query/standard_spec.rb +1 -1
  71. data/spec/api/query/stats_examples.rb +8 -8
  72. data/spec/api/query/text_field_scoping_examples.rb +5 -5
  73. data/spec/api/query/types_spec.rb +4 -4
  74. data/spec/api/search/cursor_paginated_collection_spec.rb +12 -12
  75. data/spec/api/search/dynamic_fields_spec.rb +4 -4
  76. data/spec/api/search/faceting_spec.rb +55 -52
  77. data/spec/api/search/highlighting_spec.rb +7 -7
  78. data/spec/api/search/hits_spec.rb +43 -29
  79. data/spec/api/search/paginated_collection_spec.rb +18 -18
  80. data/spec/api/search/results_spec.rb +13 -13
  81. data/spec/api/search/search_spec.rb +3 -3
  82. data/spec/api/search/stats_spec.rb +10 -10
  83. data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +19 -18
  84. data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +9 -9
  85. data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
  86. data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +10 -10
  87. data/spec/api/session_proxy/sharding_session_proxy_spec.rb +14 -13
  88. data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +2 -2
  89. data/spec/api/session_proxy/spec_helper.rb +1 -1
  90. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +9 -5
  91. data/spec/api/session_spec.rb +42 -42
  92. data/spec/api/sunspot_spec.rb +7 -4
  93. data/spec/helpers/integration_helper.rb +1 -0
  94. data/spec/integration/atomic_updates_spec.rb +25 -11
  95. data/spec/integration/dynamic_fields_spec.rb +10 -10
  96. data/spec/integration/faceting_spec.rb +252 -39
  97. data/spec/integration/field_grouping_spec.rb +35 -16
  98. data/spec/integration/field_lists_spec.rb +57 -0
  99. data/spec/integration/geospatial_spec.rb +34 -8
  100. data/spec/integration/highlighting_spec.rb +5 -5
  101. data/spec/integration/indexing_spec.rb +5 -5
  102. data/spec/integration/join_spec.rb +45 -0
  103. data/spec/integration/keyword_search_spec.rb +47 -45
  104. data/spec/integration/local_search_spec.rb +4 -4
  105. data/spec/integration/more_like_this_spec.rb +7 -7
  106. data/spec/integration/scoped_search_spec.rb +108 -108
  107. data/spec/integration/spellcheck_spec.rb +52 -7
  108. data/spec/integration/stats_spec.rb +54 -13
  109. data/spec/integration/stored_fields_spec.rb +1 -1
  110. data/spec/integration/test_pagination.rb +4 -4
  111. data/spec/integration/unicode_spec.rb +1 -1
  112. data/spec/mocks/adapters.rb +33 -0
  113. data/spec/mocks/photo.rb +14 -4
  114. data/spec/mocks/post.rb +9 -1
  115. data/spec/spec_helper.rb +11 -10
  116. data/sunspot.gemspec +3 -1
  117. metadata +49 -6
@@ -6,8 +6,8 @@ describe "grouping" do
6
6
  group :title
7
7
  end
8
8
 
9
- connection.should have_last_search_including(:group, "true")
10
- connection.should have_last_search_including(:"group.field", "title_ss")
9
+ expect(connection).to have_last_search_including(:group, "true")
10
+ expect(connection).to have_last_search_including(:"group.field", "title_ss")
11
11
  end
12
12
 
13
13
  it "sends grouping limit parameters to solr" do
@@ -17,7 +17,7 @@ describe "grouping" do
17
17
  end
18
18
  end
19
19
 
20
- connection.should have_last_search_including(:"group.limit", 2)
20
+ expect(connection).to have_last_search_including(:"group.limit", 2)
21
21
  end
22
22
 
23
23
  it "sends grouping sort parameters to solr" do
@@ -27,7 +27,7 @@ describe "grouping" do
27
27
  end
28
28
  end
29
29
 
30
- connection.should have_last_search_including(:"group.sort", "average_rating_ft asc")
30
+ expect(connection).to have_last_search_including(:"group.sort", "average_rating_ft asc")
31
31
  end
32
32
 
33
33
  it "sends grouping field parameters to solr" do
@@ -37,7 +37,7 @@ describe "grouping" do
37
37
  end
38
38
  end
39
39
 
40
- connection.should have_last_search_including(:"group.field", "title_ss")
40
+ expect(connection).to have_last_search_including(:"group.field", "title_ss")
41
41
  end
42
42
 
43
43
  it "sends grouping query parameters to solr" do
@@ -49,6 +49,6 @@ describe "grouping" do
49
49
  end
50
50
  end
51
51
 
52
- connection.should have_last_search_including(:"group.query", "category_ids_im:1")
52
+ expect(connection).to have_last_search_including(:"group.query", "category_ids_im:1")
53
53
  end
54
54
  end
@@ -3,21 +3,21 @@ shared_examples_for "query with highlighting support" do
3
3
  search do
4
4
  keywords 'test'
5
5
  end
6
- connection.should_not have_last_search_with(:hl)
6
+ expect(connection).not_to have_last_search_with(:hl)
7
7
  end
8
8
 
9
9
  it 'should enable highlighting when highlighting requested as keywords argument' do
10
10
  search do
11
11
  keywords 'test', :highlight => true
12
12
  end
13
- connection.should have_last_search_with(:hl => 'on')
13
+ expect(connection).to have_last_search_with(:hl => 'on')
14
14
  end
15
15
 
16
16
  it 'should not set highlight fields parameter if highlight fields are not passed' do
17
17
  search do
18
18
  keywords 'test', :highlight => true, :fields => [:title]
19
19
  end
20
- connection.should_not have_last_search_with(:'hl.fl')
20
+ expect(connection).not_to have_last_search_with(:'hl.fl')
21
21
  end
22
22
 
23
23
  it 'should enable highlighting on multiple fields when highlighting requested as array of fields via keywords argument' do
@@ -25,15 +25,15 @@ shared_examples_for "query with highlighting support" do
25
25
  keywords 'test', :highlight => [:title, :body]
26
26
  end
27
27
 
28
- connection.should have_last_search_with(:hl => 'on', :'hl.fl' => %w(title_text body_textsv))
28
+ expect(connection).to have_last_search_with(:hl => 'on', :'hl.fl' => %w(title_text body_textsv))
29
29
  end
30
30
 
31
31
  it 'should raise UnrecognizedFieldError if try to highlight unexisting field via keywords argument' do
32
- lambda {
32
+ expect {
33
33
  search do
34
34
  keywords 'test', :highlight => [:unknown_field]
35
35
  end
36
- }.should raise_error(Sunspot::UnrecognizedFieldError)
36
+ }.to raise_error(Sunspot::UnrecognizedFieldError)
37
37
  end
38
38
 
39
39
  it 'should enable highlighting on multiple fields when highlighting requested as list of fields via block call' do
@@ -43,7 +43,7 @@ shared_examples_for "query with highlighting support" do
43
43
  end
44
44
  end
45
45
 
46
- connection.should have_last_search_with(:hl => 'on', :'hl.fl' => %w(title_text body_textsv))
46
+ expect(connection).to have_last_search_with(:hl => 'on', :'hl.fl' => %w(title_text body_textsv))
47
47
  end
48
48
 
49
49
  it 'should enable highlighting on multiple fields for multiple search types' do
@@ -52,24 +52,24 @@ shared_examples_for "query with highlighting support" do
52
52
  highlight :body
53
53
  end
54
54
  end
55
- connection.searches.last[:'hl.fl'].to_set.should == Set['body_text', 'body_textsv']
55
+ expect(connection.searches.last[:'hl.fl'].to_set).to eq(Set['body_text', 'body_textsv'])
56
56
  end
57
57
 
58
58
  it 'should raise UnrecognizedFieldError if try to highlight unexisting field via block call' do
59
- lambda {
59
+ expect {
60
60
  search do
61
61
  keywords 'test' do
62
62
  highlight :unknown_field
63
63
  end
64
64
  end
65
- }.should raise_error(Sunspot::UnrecognizedFieldError)
65
+ }.to raise_error(Sunspot::UnrecognizedFieldError)
66
66
  end
67
67
 
68
68
  it 'should set internal formatting' do
69
69
  search do
70
70
  keywords 'test', :highlight => true
71
71
  end
72
- connection.should have_last_search_with(
72
+ expect(connection).to have_last_search_with(
73
73
  :"hl.simple.pre" => '@@@hl@@@',
74
74
  :"hl.simple.post" => '@@@endhl@@@'
75
75
  )
@@ -81,7 +81,7 @@ shared_examples_for "query with highlighting support" do
81
81
  highlight :title
82
82
  end
83
83
  end
84
- connection.should have_last_search_with(
84
+ expect(connection).to have_last_search_with(
85
85
  :"hl.fl" => %w(title_text)
86
86
  )
87
87
  end
@@ -90,7 +90,7 @@ shared_examples_for "query with highlighting support" do
90
90
  search do
91
91
  keywords 'test', :highlight => :body
92
92
  end
93
- connection.should have_last_search_with(
93
+ expect(connection).to have_last_search_with(
94
94
  :"hl.simple.pre" => '@@@hl@@@',
95
95
  :"hl.simple.post" => '@@@endhl@@@'
96
96
  )
@@ -102,7 +102,7 @@ shared_examples_for "query with highlighting support" do
102
102
  highlight :max_snippets => 3
103
103
  end
104
104
  end
105
- connection.should have_last_search_with(
105
+ expect(connection).to have_last_search_with(
106
106
  :"hl.snippets" => 3
107
107
  )
108
108
  end
@@ -113,7 +113,7 @@ shared_examples_for "query with highlighting support" do
113
113
  highlight :title, :max_snippets => 3
114
114
  end
115
115
  end
116
- connection.should have_last_search_with(
116
+ expect(connection).to have_last_search_with(
117
117
  :"hl.fl" => %w(title_text),
118
118
  :"f.title_text.hl.snippets" => 3
119
119
  )
@@ -125,7 +125,7 @@ shared_examples_for "query with highlighting support" do
125
125
  highlight :fragment_size => 200
126
126
  end
127
127
  end
128
- connection.should have_last_search_with(
128
+ expect(connection).to have_last_search_with(
129
129
  :"hl.fragsize" => 200
130
130
  )
131
131
  end
@@ -136,7 +136,7 @@ shared_examples_for "query with highlighting support" do
136
136
  highlight :title, :fragment_size => 200
137
137
  end
138
138
  end
139
- connection.should have_last_search_with(
139
+ expect(connection).to have_last_search_with(
140
140
  :"f.title_text.hl.fragsize" => 200
141
141
  )
142
142
  end
@@ -147,7 +147,7 @@ shared_examples_for "query with highlighting support" do
147
147
  highlight :merge_contiguous_fragments => true
148
148
  end
149
149
  end
150
- connection.should have_last_search_with(
150
+ expect(connection).to have_last_search_with(
151
151
  :"hl.mergeContiguous" => 'true'
152
152
  )
153
153
  end
@@ -158,7 +158,7 @@ shared_examples_for "query with highlighting support" do
158
158
  highlight :title, :merge_contiguous_fragments => true
159
159
  end
160
160
  end
161
- connection.should have_last_search_with(
161
+ expect(connection).to have_last_search_with(
162
162
  :"f.title_text.hl.mergeContiguous" => 'true'
163
163
  )
164
164
  end
@@ -169,7 +169,7 @@ shared_examples_for "query with highlighting support" do
169
169
  highlight :phrase_highlighter => true
170
170
  end
171
171
  end
172
- connection.should have_last_search_with(
172
+ expect(connection).to have_last_search_with(
173
173
  :"hl.usePhraseHighlighter" => 'true'
174
174
  )
175
175
  end
@@ -180,7 +180,7 @@ shared_examples_for "query with highlighting support" do
180
180
  highlight :title, :phrase_highlighter => true
181
181
  end
182
182
  end
183
- connection.should have_last_search_with(
183
+ expect(connection).to have_last_search_with(
184
184
  :"f.title_text.hl.usePhraseHighlighter" => 'true'
185
185
  )
186
186
  end
@@ -191,7 +191,7 @@ shared_examples_for "query with highlighting support" do
191
191
  highlight :phrase_highlighter => true, :require_field_match => true
192
192
  end
193
193
  end
194
- connection.should have_last_search_with(
194
+ expect(connection).to have_last_search_with(
195
195
  :"hl.requireFieldMatch" => 'true'
196
196
  )
197
197
  end
@@ -202,7 +202,7 @@ shared_examples_for "query with highlighting support" do
202
202
  highlight :title, :phrase_highlighter => true, :require_field_match => true
203
203
  end
204
204
  end
205
- connection.should have_last_search_with(
205
+ expect(connection).to have_last_search_with(
206
206
  :"f.title_text.hl.requireFieldMatch" => 'true'
207
207
  )
208
208
  end
@@ -214,7 +214,7 @@ shared_examples_for "query with highlighting support" do
214
214
  highlight :body, :max_snippets => 1
215
215
  end
216
216
  end
217
- connection.should have_last_search_with(
217
+ expect(connection).to have_last_search_with(
218
218
  :"hl.fl" => %w(title_text body_textsv),
219
219
  :"f.title_text.hl.snippets" => 2,
220
220
  :"f.body_textsv.hl.snippets" => 1
@@ -227,7 +227,7 @@ shared_examples_for "query with highlighting support" do
227
227
  highlight :title, :formatter => 'formatter'
228
228
  end
229
229
  end
230
- connection.should have_last_search_with(
230
+ expect(connection).to have_last_search_with(
231
231
  :"f.title_text.hl.formatter" => 'formatter'
232
232
  )
233
233
  end
@@ -238,7 +238,7 @@ shared_examples_for "query with highlighting support" do
238
238
  highlight :title, :fragmenter => 'example_fragmenter'
239
239
  end
240
240
  end
241
- connection.should have_last_search_with(
241
+ expect(connection).to have_last_search_with(
242
242
  :"f.title_text.hl.fragmenter" => 'example_fragmenter'
243
243
  )
244
244
  end
@@ -5,7 +5,7 @@ describe 'join' do
5
5
  session.search PhotoContainer do
6
6
  with(:caption, 'blah')
7
7
  end
8
- connection.should have_last_search_including(
8
+ expect(connection).to have_last_search_including(
9
9
  :fq, "{!join from=photo_container_id_i to=id_i}caption_s:blah")
10
10
  end
11
11
 
@@ -13,7 +13,7 @@ describe 'join' do
13
13
  session.search PhotoContainer do
14
14
  with(:photo_rating).greater_than(3)
15
15
  end
16
- connection.should have_last_search_including(
16
+ expect(connection).to have_last_search_including(
17
17
  :fq, "{!join from=photo_container_id_i to=id_i}average_rating_ft:{3\\.0 TO *}")
18
18
  end
19
19
  end
@@ -16,42 +16,42 @@ describe 'more_like_this' do
16
16
  it 'should query passed in object' do
17
17
  p = Post.new
18
18
  session.more_like_this(p)
19
- connection.should have_last_search_with(:q => "id:Post\\ #{p.id}")
19
+ expect(connection).to have_last_search_with(:q => "id:Post\\ #{p.id}")
20
20
  end
21
21
 
22
22
  it 'should use more_like_this fields if no fields specified' do
23
23
  session.more_like_this(Post.new)
24
- connection.searches.last[:"mlt.fl"].split(',').sort.should == %w(body_textsv tags_textv)
24
+ expect(connection.searches.last[:"mlt.fl"].split(',').sort).to eq(%w(body_textsv tags_textv))
25
25
  end
26
26
 
27
27
  it 'should use more_like_this fields if specified' do
28
28
  session.more_like_this(Post.new) do
29
29
  fields :body
30
30
  end
31
- connection.should have_last_search_with(:"mlt.fl" => "body_textsv")
31
+ expect(connection).to have_last_search_with(:"mlt.fl" => "body_textsv")
32
32
  end
33
33
 
34
34
  it 'assigns boosts to fields when specified' do
35
35
  session.more_like_this(Post.new) do
36
36
  fields :body, :tags => 8
37
37
  end
38
- connection.searches.last[:"mlt.fl"].split(',').sort.should == %w(body_textsv tags_textv)
39
- connection.should have_last_search_with(:"mlt.qf" => "tags_textv^8")
38
+ expect(connection.searches.last[:"mlt.fl"].split(',').sort).to eq(%w(body_textsv tags_textv))
39
+ expect(connection).to have_last_search_with(:"mlt.qf" => "tags_textv^8")
40
40
  end
41
41
 
42
42
  it 'doesn\'t assign boosts to fields when not specified' do
43
43
  session.more_like_this(Post.new) do
44
44
  fields :body
45
45
  end
46
- connection.should_not have_last_search_with(:qf)
46
+ expect(connection).not_to have_last_search_with(:qf)
47
47
  end
48
48
 
49
49
  it 'should raise ArgumentError if a field is not setup for more_like_this' do
50
- lambda do
50
+ expect do
51
51
  session.more_like_this(Post.new) do
52
52
  fields :title
53
53
  end
54
- end.should raise_error(ArgumentError)
54
+ end.to raise_error(ArgumentError)
55
55
  end
56
56
 
57
57
  it 'should accept options' do
@@ -63,12 +63,12 @@ describe 'more_like_this' do
63
63
  maximum_query_terms 5
64
64
  boost_by_relevance false
65
65
  end
66
- connection.should have_last_search_with(:"mlt.mintf" => 1)
67
- connection.should have_last_search_with(:"mlt.mindf" => 2)
68
- connection.should have_last_search_with(:"mlt.minwl" => 3)
69
- connection.should have_last_search_with(:"mlt.maxwl" => 4)
70
- connection.should have_last_search_with(:"mlt.maxqt" => 5)
71
- connection.should have_last_search_with(:"mlt.boost" => false)
66
+ expect(connection).to have_last_search_with(:"mlt.mintf" => 1)
67
+ expect(connection).to have_last_search_with(:"mlt.mindf" => 2)
68
+ expect(connection).to have_last_search_with(:"mlt.minwl" => 3)
69
+ expect(connection).to have_last_search_with(:"mlt.maxwl" => 4)
70
+ expect(connection).to have_last_search_with(:"mlt.maxqt" => 5)
71
+ expect(connection).to have_last_search_with(:"mlt.boost" => false)
72
72
  end
73
73
 
74
74
  it 'should accept short options' do
@@ -80,45 +80,45 @@ describe 'more_like_this' do
80
80
  maxqt 5
81
81
  boost true
82
82
  end
83
- connection.should have_last_search_with(:"mlt.mintf" => 1)
84
- connection.should have_last_search_with(:"mlt.mindf" => 2)
85
- connection.should have_last_search_with(:"mlt.minwl" => 3)
86
- connection.should have_last_search_with(:"mlt.maxwl" => 4)
87
- connection.should have_last_search_with(:"mlt.maxqt" => 5)
88
- connection.should have_last_search_with(:"mlt.boost" => true)
83
+ expect(connection).to have_last_search_with(:"mlt.mintf" => 1)
84
+ expect(connection).to have_last_search_with(:"mlt.mindf" => 2)
85
+ expect(connection).to have_last_search_with(:"mlt.minwl" => 3)
86
+ expect(connection).to have_last_search_with(:"mlt.maxwl" => 4)
87
+ expect(connection).to have_last_search_with(:"mlt.maxqt" => 5)
88
+ expect(connection).to have_last_search_with(:"mlt.boost" => true)
89
89
  end
90
90
 
91
91
  it 'paginates using default per_page when page not provided' do
92
92
  session.more_like_this(Post.new)
93
- connection.should have_last_search_with(:rows => 30)
93
+ expect(connection).to have_last_search_with(:rows => 30)
94
94
  end
95
95
 
96
96
  it 'paginates using default per_page when page provided' do
97
97
  session.more_like_this(Post.new) do
98
98
  paginate :page => 2
99
99
  end
100
- connection.should have_last_search_with(:rows => 30, :start => 30)
100
+ expect(connection).to have_last_search_with(:rows => 30, :start => 30)
101
101
  end
102
102
 
103
103
  it 'paginates using provided per_page' do
104
104
  session.more_like_this(Post.new) do
105
105
  paginate :page => 4, :per_page => 15
106
106
  end
107
- connection.should have_last_search_with(:rows => 15, :start => 45)
107
+ expect(connection).to have_last_search_with(:rows => 15, :start => 45)
108
108
  end
109
109
 
110
110
  it 'defaults to page 1 if no :page argument given' do
111
111
  session.more_like_this(Post.new) do
112
112
  paginate :per_page => 15
113
113
  end
114
- connection.should have_last_search_with(:rows => 15, :start => 0)
114
+ expect(connection).to have_last_search_with(:rows => 15, :start => 0)
115
115
  end
116
116
 
117
117
  it 'paginates from string argument' do
118
118
  session.more_like_this(Post.new) do
119
119
  paginate :page => '3', :per_page => '15'
120
120
  end
121
- connection.should have_last_search_with(:rows => 15, :start => 30)
121
+ expect(connection).to have_last_search_with(:rows => 15, :start => 30)
122
122
  end
123
123
 
124
124
  it "should send query to solr with adjusted parameters (keyword example)" do
@@ -128,8 +128,8 @@ describe 'more_like_this' do
128
128
  params[:some] = 'param'
129
129
  end
130
130
  end
131
- connection.should have_last_search_with(:q => 'new search')
132
- connection.should have_last_search_with(:some => 'param')
131
+ expect(connection).to have_last_search_with(:q => 'new search')
132
+ expect(connection).to have_last_search_with(:some => 'param')
133
133
  end
134
134
 
135
135
  it "should send query to solr with adjusted parameters in multiple blocks" do
@@ -141,8 +141,8 @@ describe 'more_like_this' do
141
141
  params[:some] = 'param'
142
142
  end
143
143
  end
144
- connection.should have_last_search_with(:q => 'new search')
145
- connection.should have_last_search_with(:some => 'param')
144
+ expect(connection).to have_last_search_with(:q => 'new search')
145
+ expect(connection).to have_last_search_with(:some => 'param')
146
146
  end
147
147
 
148
148
  private
@@ -1,70 +1,70 @@
1
1
  shared_examples_for 'sortable query' do
2
2
  it 'paginates using default per_page when page not provided' do
3
3
  search
4
- connection.should have_last_search_with(:rows => 30)
4
+ expect(connection).to have_last_search_with(:rows => 30)
5
5
  end
6
6
 
7
7
  it 'paginates using default per_page when page provided' do
8
8
  search do
9
9
  paginate :page => 2
10
10
  end
11
- connection.should have_last_search_with(:rows => 30, :start => 30)
11
+ expect(connection).to have_last_search_with(:rows => 30, :start => 30)
12
12
  end
13
13
 
14
14
  it 'paginates using provided per_page' do
15
15
  search do
16
16
  paginate :page => 4, :per_page => 15
17
17
  end
18
- connection.should have_last_search_with(:rows => 15, :start => 45)
18
+ expect(connection).to have_last_search_with(:rows => 15, :start => 45)
19
19
  end
20
20
 
21
21
  it 'defaults to page 1 if no :page argument given' do
22
22
  search do
23
23
  paginate :per_page => 15
24
24
  end
25
- connection.should have_last_search_with(:rows => 15, :start => 0)
25
+ expect(connection).to have_last_search_with(:rows => 15, :start => 0)
26
26
  end
27
27
 
28
28
  it 'paginates with an offset' do
29
29
  search do
30
30
  paginate :per_page => 15, :offset => 3
31
31
  end
32
- connection.should have_last_search_with(:rows => 15, :start => 3)
32
+ expect(connection).to have_last_search_with(:rows => 15, :start => 3)
33
33
  end
34
34
 
35
35
  it 'paginates with an offset as a string' do
36
36
  search do
37
37
  paginate :per_page => 15, :offset => '3'
38
38
  end
39
- connection.should have_last_search_with(:rows => 15, :start => 3)
39
+ expect(connection).to have_last_search_with(:rows => 15, :start => 3)
40
40
  end
41
41
 
42
42
  it 'paginates from string argument' do
43
43
  search do
44
44
  paginate :page => '3', :per_page => '15'
45
45
  end
46
- connection.should have_last_search_with(:rows => 15, :start => 30)
46
+ expect(connection).to have_last_search_with(:rows => 15, :start => 30)
47
47
  end
48
48
 
49
49
  it 'paginates with initial cursor' do
50
50
  search do
51
51
  paginate :cursor => '*', :per_page => 15
52
52
  end
53
- connection.should have_last_search_with(:rows => 15, :cursorMark => '*')
53
+ expect(connection).to have_last_search_with(:rows => 15, :cursorMark => '*')
54
54
  end
55
55
 
56
56
  it 'paginates with given cursor' do
57
57
  search do
58
58
  paginate :cursor => 'AoIIP4AAACxQcm9maWxlIDEwMTk='
59
59
  end
60
- connection.should have_last_search_with(:cursorMark => 'AoIIP4AAACxQcm9maWxlIDEwMTk=')
60
+ expect(connection).to have_last_search_with(:cursorMark => 'AoIIP4AAACxQcm9maWxlIDEwMTk=')
61
61
  end
62
62
 
63
63
  it 'orders by a single field' do
64
64
  search do
65
65
  order_by :average_rating, :desc
66
66
  end
67
- connection.should have_last_search_with(:sort => 'average_rating_ft desc')
67
+ expect(connection).to have_last_search_with(:sort => 'average_rating_ft desc')
68
68
  end
69
69
 
70
70
  it 'orders by multiple fields' do
@@ -72,80 +72,80 @@ shared_examples_for 'sortable query' do
72
72
  order_by :average_rating, :desc
73
73
  order_by :sort_title, :asc
74
74
  end
75
- connection.should have_last_search_with(:sort => 'average_rating_ft desc, sort_title_s asc')
75
+ expect(connection).to have_last_search_with(:sort => 'average_rating_ft desc, sort_title_s asc')
76
76
  end
77
77
 
78
78
  it 'orders by random' do
79
79
  search do
80
80
  order_by :random
81
81
  end
82
- connection.searches.last[:sort].should =~ /^random_\d+ asc$/
82
+ expect(connection.searches.last[:sort]).to match(/^random_\d+ asc$/)
83
83
  end
84
84
 
85
85
  it 'orders by random with declared direction' do
86
86
  search do
87
87
  order_by :random, :desc
88
88
  end
89
- connection.searches.last[:sort].should =~ /^random_\d+ desc$/
89
+ expect(connection.searches.last[:sort]).to match(/^random_\d+ desc$/)
90
90
  end
91
91
 
92
92
  it 'orders by random with provided seed value' do
93
93
  search do
94
94
  order_by :random, :seed => 9001
95
95
  end
96
- connection.searches.last[:sort].should =~ /^random_9001 asc$/
96
+ expect(connection.searches.last[:sort]).to match(/^random_9001 asc$/)
97
97
  end
98
98
 
99
99
  it 'orders by random with provided seed value and direction' do
100
100
  search do
101
101
  order_by :random, :seed => 12345, :direction => :desc
102
102
  end
103
- connection.searches.last[:sort].should =~ /^random_12345 desc$/
103
+ expect(connection.searches.last[:sort]).to match(/^random_12345 desc$/)
104
104
  end
105
105
 
106
106
  it 'orders by score' do
107
107
  search do
108
108
  order_by :score, :desc
109
109
  end
110
- connection.should have_last_search_with(:sort => 'score desc')
110
+ expect(connection).to have_last_search_with(:sort => 'score desc')
111
111
  end
112
112
 
113
113
  it 'orders by geodist' do
114
114
  search do
115
115
  order_by_geodist :coordinates_new, 32, -68, :desc
116
116
  end
117
- connection.should have_last_search_with(:sort => 'geodist(coordinates_new_ll,32,-68) desc')
117
+ expect(connection).to have_last_search_with(:sort => 'geodist(coordinates_new_ll,32,-68) desc')
118
118
  end
119
119
 
120
120
  it 'throws an ArgumentError if a bogus order direction is given' do
121
- lambda do
121
+ expect do
122
122
  search do
123
123
  order_by :sort_title, :sideways
124
124
  end
125
- end.should raise_error(ArgumentError)
125
+ end.to raise_error(ArgumentError)
126
126
  end
127
127
 
128
128
  it 'throws an UnrecognizedFieldError if :distance is given for sort' do
129
- lambda do
129
+ expect do
130
130
  search do
131
131
  order_by :distance, :asc
132
132
  end
133
- end.should raise_error(Sunspot::UnrecognizedFieldError)
133
+ end.to raise_error(Sunspot::UnrecognizedFieldError)
134
134
  end
135
135
 
136
136
  it 'does not allow ordering by multiple-value fields' do
137
- lambda do
137
+ expect do
138
138
  search do
139
139
  order_by :category_ids
140
140
  end
141
- end.should raise_error(ArgumentError)
141
+ end.to raise_error(ArgumentError)
142
142
  end
143
143
 
144
144
  it 'raises ArgumentError if bogus argument given to paginate' do
145
- lambda do
145
+ expect do
146
146
  search do
147
147
  paginate :page => 4, :ugly => :puppy
148
148
  end
149
- end.should raise_error(ArgumentError)
149
+ end.to raise_error(ArgumentError)
150
150
  end
151
151
  end