rspec-solr 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,157 +2,154 @@ require 'spec_helper'
2
2
  require 'rspec-solr'
3
3
 
4
4
  describe RSpecSolr do
5
-
6
5
  context "shouldn't break RSpec #have matcher" do
7
- it "for Array" do
8
- [1,2,3].should have(3).items
9
- [1,2,3].should_not have(4).items
10
- [1,2,3].should have_at_least(2).items
11
- [1,2,3].should have_at_least(1).item
12
- [1,2,3].should have_at_most(5).items
13
- end
14
-
15
- it "for Hash" do
16
- {:k1 => 'v1', :k2 => 'v2', :k3 => 'v3'}.should have_exactly(3).items
17
- {:k1 => 'v1', :k2 => 'v2', :k3 => 'v3'}.should_not have(4).items
18
- {:k1 => 'v1', :k2 => 'v2', :k3 => 'v3'}.should have_at_least(2).items
19
- {:k1 => 'v1', :k2 => 'v2', :k3 => 'v3'}.should have_at_most(5).items
20
- end
21
-
22
- it "for String" do
23
- "this string".should have(11).characters
24
- "this string".should_not have(12).characters
25
- end
26
-
27
- it "passes args to target" do
28
- target = mock("target")
29
- target.should_receive(:items).with("arg1","arg2").and_return([1,2,3])
30
- target.should have(3).items("arg1","arg2")
31
- end
32
- it "passes block to target" do
33
- target = mock("target")
34
- block = lambda { 5 }
35
- target.should_receive(:items).with("arg1","arg2", block).and_return([1,2,3])
36
- target.should have(3).items("arg1","arg2", block)
6
+ it 'for Array' do
7
+ expect([1, 2, 3]).to have(3).items
8
+ expect([1, 2, 3]).not_to have(4).items
9
+ expect([1, 2, 3]).to have_at_least(2).items
10
+ expect([1, 2, 3]).to have_at_least(1).item
11
+ expect([1, 2, 3]).to have_at_most(5).items
12
+ end
13
+
14
+ it 'for Hash' do
15
+ expect(k1: 'v1', k2: 'v2', k3: 'v3').to have_exactly(3).items
16
+ expect(k1: 'v1', k2: 'v2', k3: 'v3').not_to have(4).items
17
+ expect(k1: 'v1', k2: 'v2', k3: 'v3').to have_at_least(2).items
18
+ expect(k1: 'v1', k2: 'v2', k3: 'v3').to have_at_most(5).items
19
+ end
20
+
21
+ it 'for String' do
22
+ expect('this string').to have(11).characters
23
+ expect('this string').not_to have(12).characters
24
+ end
25
+
26
+ it 'passes args to target' do
27
+ target = double('target')
28
+ expect(target).to receive(:items).with('arg1', 'arg2').and_return([1, 2, 3])
29
+ expect(target).to have(3).items('arg1', 'arg2')
30
+ end
31
+ it 'passes block to target' do
32
+ target = double('target')
33
+ block = -> { 5 }
34
+ expect(target).to receive(:items).with('arg1', 'arg2', block).and_return([1, 2, 3])
35
+ expect(target).to have(3).items('arg1', 'arg2', block)
37
36
  end
38
37
  end
39
-
38
+
40
39
  # fixtures at end of this file
41
40
 
42
- context "should have(n).documents" do
43
-
41
+ context 'should have(n).documents' do
44
42
  it "pluralizes 'documents'" do
45
- @solr_resp_1_doc.should have(1).document
46
- end
47
-
48
- it "passes if target response has n documents" do
49
- @solr_resp_5_docs.should have(5).documents
50
- @solr_resp_no_docs.should have(0).documents
51
- end
52
-
53
- it "converts :no to 0" do
54
- @solr_resp_no_docs.should have(:no).documents
55
- end
56
-
57
- it "converts a String argument to Integer" do
58
- @solr_resp_5_docs.should have('5').documents
59
- end
60
-
61
- it "fails if target response has < n documents" do
62
- lambda {
63
- @solr_resp_5_docs.should have(6).documents
64
- }.should fail_with("expected 6 documents, got 5")
65
- lambda {
66
- @solr_resp_no_docs.should have(1).document
67
- }.should fail_with("expected 1 document, got 0")
68
- end
69
-
70
- it "fails if target response has > n documents" do
71
- lambda {
72
- @solr_resp_5_docs.should have(4).documents
73
- }.should fail_with("expected 4 documents, got 5")
74
- lambda {
75
- @solr_resp_1_doc.should have(0).documents
76
- }.should fail_with("expected 0 documents, got 1")
77
- end
78
-
43
+ expect(@solr_resp_1_doc).to have(1).document
44
+ end
45
+
46
+ it 'passes if target response has n documents' do
47
+ expect(@solr_resp_5_docs).to have(5).documents
48
+ expect(@solr_resp_no_docs).to have(0).documents
49
+ end
50
+
51
+ it 'converts :no to 0' do
52
+ expect(@solr_resp_no_docs).to have(:no).documents
53
+ end
54
+
55
+ it 'converts a String argument to Integer' do
56
+ expect(@solr_resp_5_docs).to have('5').documents
57
+ end
58
+
59
+ it 'fails if target response has < n documents' do
60
+ expect do
61
+ expect(@solr_resp_5_docs).to have(6).documents
62
+ end.to raise_error.with_message 'expected 6 documents, got 5'
63
+ expect do
64
+ expect(@solr_resp_no_docs).to have(1).document
65
+ end.to raise_error.with_message 'expected 1 document, got 0'
66
+ end
67
+
68
+ it 'fails if target response has > n documents' do
69
+ expect do
70
+ expect(@solr_resp_5_docs).to have(4).documents
71
+ end.to raise_error.with_message 'expected 4 documents, got 5'
72
+ expect do
73
+ expect(@solr_resp_1_doc).to have(0).documents
74
+ end.to raise_error.with_message 'expected 0 documents, got 1'
75
+ end
79
76
  end
80
-
81
- context "should_not have(n).documents" do
82
- it "passes if target response has < n documents" do
83
- @solr_resp_5_docs.should_not have(6).documents
84
- @solr_resp_1_doc.should_not have(2).documents
85
- @solr_resp_no_docs.should_not have(1).document
86
- end
87
-
88
- it "passes if target response has > n documents" do
89
- @solr_resp_5_docs.should_not have(4).documents
90
- @solr_resp_1_doc.should_not have(0).documents
91
- @solr_resp_no_docs.should_not have(-1).documents
92
- end
93
-
94
- it "fails if target response has n documents" do
95
- lambda {
96
- @solr_resp_5_docs.should_not have(5).documents
97
- }.should fail_with("expected target not to have 5 documents, got 5")
77
+
78
+ context 'should_not have(n).documents' do
79
+ it 'passes if target response has < n documents' do
80
+ expect(@solr_resp_5_docs).not_to have(6).documents
81
+ expect(@solr_resp_1_doc).not_to have(2).documents
82
+ expect(@solr_resp_no_docs).not_to have(1).document
83
+ end
84
+
85
+ it 'passes if target response has > n documents' do
86
+ expect(@solr_resp_5_docs).not_to have(4).documents
87
+ expect(@solr_resp_1_doc).not_to have(0).documents
88
+ expect(@solr_resp_no_docs).not_to have(-1).documents
89
+ end
90
+
91
+ it 'fails if target response has n documents' do
92
+ expect do
93
+ expect(@solr_resp_5_docs).not_to have(5).documents
94
+ end.to raise_error.with_message 'expected target not to have 5 documents, got 5'
98
95
  end
99
96
  end
100
-
101
- context "should have_exactly(n).documents" do
102
- it "passes if target response has n documents" do
103
- @solr_resp_5_docs.should have_exactly(5).documents
104
- @solr_resp_no_docs.should have_exactly(0).documents
105
- end
106
- it "converts :no to 0" do
107
- @solr_resp_no_docs.should have_exactly(:no).documents
108
- end
109
- it "fails if target response has < n documents" do
110
- lambda {
111
- @solr_resp_5_docs.should have_exactly(6).documents
112
- }.should fail_with("expected 6 documents, got 5")
113
- lambda {
114
- @solr_resp_no_docs.should have_exactly(1).document
115
- }.should fail_with("expected 1 document, got 0")
116
- end
117
-
118
- it "fails if target response has > n documents" do
119
- lambda {
120
- @solr_resp_5_docs.should have_exactly(4).documents
121
- }.should fail_with("expected 4 documents, got 5")
122
- lambda {
123
- @solr_resp_1_doc.should have_exactly(0).documents
124
- }.should fail_with("expected 0 documents, got 1")
97
+
98
+ context 'should have_exactly(n).documents' do
99
+ it 'passes if target response has n documents' do
100
+ expect(@solr_resp_5_docs).to have_exactly(5).documents
101
+ expect(@solr_resp_no_docs).to have_exactly(0).documents
102
+ end
103
+ it 'converts :no to 0' do
104
+ expect(@solr_resp_no_docs).to have_exactly(:no).documents
105
+ end
106
+ it 'fails if target response has < n documents' do
107
+ expect do
108
+ expect(@solr_resp_5_docs).to have_exactly(6).documents
109
+ end.to raise_error.with_message 'expected 6 documents, got 5'
110
+ expect do
111
+ expect(@solr_resp_no_docs).to have_exactly(1).document
112
+ end.to raise_error.with_message 'expected 1 document, got 0'
113
+ end
114
+
115
+ it 'fails if target response has > n documents' do
116
+ expect do
117
+ expect(@solr_resp_5_docs).to have_exactly(4).documents
118
+ end.to raise_error.with_message 'expected 4 documents, got 5'
119
+ expect do
120
+ expect(@solr_resp_1_doc).to have_exactly(0).documents
121
+ end.to raise_error.with_message 'expected 0 documents, got 1'
125
122
  end
126
123
  end
127
-
128
- context "should have_at_least(n).documents" do
129
- it "passes if target response has n documents" do
130
- @solr_resp_5_docs.should have_at_least(5).documents
131
- @solr_resp_1_doc.should have_at_least(1).document
132
- @solr_resp_no_docs.should have_at_least(0).documents
133
- end
134
-
135
- it "passes if target response has > n documents" do
136
- @solr_resp_5_docs.should have_at_least(4).documents
137
- @solr_resp_1_doc.should have_at_least(0).documents
138
- end
139
-
140
- it "fails if target response has < n documents" do
141
- lambda {
142
- @solr_resp_5_docs.should have_at_least(6).documents
143
- }.should fail_matching("expected at least 6 documents, got 5")
144
- lambda {
145
- @solr_resp_no_docs.should have_at_least(1).document
146
- }.should fail_matching("expected at least 1 document, got 0")
147
- end
148
-
149
- it "provides educational negative failure messages" do
124
+
125
+ context 'should have_at_least(n).documents' do
126
+ it 'passes if target response has n documents' do
127
+ expect(@solr_resp_5_docs).to have_at_least(5).documents
128
+ expect(@solr_resp_1_doc).to have_at_least(1).document
129
+ expect(@solr_resp_no_docs).to have_at_least(0).documents
130
+ end
131
+
132
+ it 'passes if target response has > n documents' do
133
+ expect(@solr_resp_5_docs).to have_at_least(4).documents
134
+ expect(@solr_resp_1_doc).to have_at_least(0).documents
135
+ end
136
+
137
+ it 'fails if target response has < n documents' do
138
+ expect do
139
+ expect(@solr_resp_5_docs).to have_at_least(6).documents
140
+ end.to raise_error.with_message 'expected at least 6 documents, got 5'
141
+ expect do
142
+ expect(@solr_resp_no_docs).to have_at_least(1).document
143
+ end.to raise_error.with_message 'expected at least 1 document, got 0'
144
+ end
145
+
146
+ it 'provides educational negative failure messages' do
150
147
  # given
151
148
  my_matcher = have_at_least(6).documents
152
149
  # when
153
150
  my_matcher.matches?(@solr_resp_5_docs)
154
- # then
155
- my_matcher.failure_message_for_should_not.should eq <<-EOF
151
+ # then
152
+ expect(my_matcher.failure_message_for_should_not).to eq <<-EOF
156
153
  Isn't life confusing enough?
157
154
  Instead of having to figure out the meaning of this:
158
155
  expect(actual).not_to have_at_least(6).documents
@@ -161,35 +158,35 @@ We recommend that you use this instead:
161
158
  EOF
162
159
  end
163
160
  end
164
-
165
- context "should have_at_most(n).documents" do
166
- it "passes if target response has n documents" do
167
- @solr_resp_5_docs.should have_at_most(5).documents
168
- @solr_resp_1_doc.should have_at_most(1).document
169
- @solr_resp_no_docs.should have_at_most(0).documents
161
+
162
+ context 'should have_at_most(n).documents' do
163
+ it 'passes if target response has n documents' do
164
+ expect(@solr_resp_5_docs).to have_at_most(5).documents
165
+ expect(@solr_resp_1_doc).to have_at_most(1).document
166
+ expect(@solr_resp_no_docs).to have_at_most(0).documents
170
167
  end
171
168
 
172
- it "passes if target response has < n documents" do
173
- @solr_resp_5_docs.should have_at_most(6).documents
174
- @solr_resp_no_docs.should have_at_most(1).document
169
+ it 'passes if target response has < n documents' do
170
+ expect(@solr_resp_5_docs).to have_at_most(6).documents
171
+ expect(@solr_resp_no_docs).to have_at_most(1).document
175
172
  end
176
173
 
177
- it "fails if target response has > n documents" do
178
- lambda {
179
- @solr_resp_5_docs.should have_at_most(4).documents
180
- }.should fail_matching("expected at most 4 documents, got 5")
181
- lambda {
182
- @solr_resp_1_doc.should have_at_most(0).documents
183
- }.should fail_matching("expected at most 0 documents, got 1")
174
+ it 'fails if target response has > n documents' do
175
+ expect do
176
+ expect(@solr_resp_5_docs).to have_at_most(4).documents
177
+ end.to raise_error.with_message 'expected at most 4 documents, got 5'
178
+ expect do
179
+ expect(@solr_resp_1_doc).to have_at_most(0).documents
180
+ end.to raise_error.with_message 'expected at most 0 documents, got 1'
184
181
  end
185
182
 
186
- it "provides educational negative failure messages" do
183
+ it 'provides educational negative failure messages' do
187
184
  # given
188
185
  my_matcher = have_at_most(4).documents
189
186
  # when
190
187
  my_matcher.matches?(@solr_resp_5_docs)
191
- # then
192
- my_matcher.failure_message_for_should_not.should eq <<-EOF
188
+ # then
189
+ expect(my_matcher.failure_message_for_should_not).to eq <<-EOF
193
190
  Isn't life confusing enough?
194
191
  Instead of having to figure out the meaning of this:
195
192
  expect(actual).not_to have_at_most(4).documents
@@ -198,53 +195,47 @@ We recommend that you use this instead:
198
195
  EOF
199
196
  end
200
197
  end
201
-
202
- it "should pass according to total Solr docs matching the query, not the number of docs in THIS response" do
203
- solr_resp = RSpecSolr::SolrResponseHash.new({ "response" =>
204
- { "numFound" => 3,
205
- "start" => 0,
206
- "rows" => 1,
207
- "docs" => [ {"id"=>"111"} ]
208
- }
209
- })
210
- solr_resp.should have(3).documents
211
- solr_resp.should_not have(1).document
212
- solr_resp = RSpecSolr::SolrResponseHash.new({ "response" =>
213
- { "numFound" => 3,
214
- "start" => 0,
215
- "rows" => 0
216
- }
217
- })
218
- solr_resp.should have(3).documents
198
+
199
+ it 'should pass according to total Solr docs matching the query, not the number of docs in THIS response' do
200
+ solr_resp = RSpecSolr::SolrResponseHash.new('response' =>
201
+ { 'numFound' => 3,
202
+ 'start' => 0,
203
+ 'rows' => 1,
204
+ 'docs' => [{ 'id' => '111' }]
205
+ })
206
+ expect(solr_resp).to have(3).documents
207
+ expect(solr_resp).not_to have(1).document
208
+ solr_resp = RSpecSolr::SolrResponseHash.new('response' =>
209
+ { 'numFound' => 3,
210
+ 'start' => 0,
211
+ 'rows' => 0
212
+ })
213
+ expect(solr_resp).to have(3).documents
219
214
  end
220
-
215
+
221
216
  before(:all) do
222
- @solr_resp_1_doc = RSpecSolr::SolrResponseHash.new({ "response" =>
223
- { "numFound" => 1,
224
- "start" => 0,
225
- "docs" => [ {"id"=>"111"} ]
226
- }
227
- })
228
-
229
- @solr_resp_5_docs = RSpecSolr::SolrResponseHash.new({ "response" =>
230
- { "numFound" => 5,
231
- "start" => 0,
232
- "docs" =>
233
- [ {"id"=>"111"},
234
- {"id"=>"222"},
235
- {"id"=>"333"},
236
- {"id"=>"444"},
237
- {"id"=>"555"}
217
+ @solr_resp_1_doc = RSpecSolr::SolrResponseHash.new('response' =>
218
+ { 'numFound' => 1,
219
+ 'start' => 0,
220
+ 'docs' => [{ 'id' => '111' }]
221
+ })
222
+
223
+ @solr_resp_5_docs = RSpecSolr::SolrResponseHash.new('response' =>
224
+ { 'numFound' => 5,
225
+ 'start' => 0,
226
+ 'docs' =>
227
+ [{ 'id' => '111' },
228
+ { 'id' => '222' },
229
+ { 'id' => '333' },
230
+ { 'id' => '444' },
231
+ { 'id' => '555' }
238
232
  ]
239
- }
240
- })
241
-
242
- @solr_resp_no_docs = RSpecSolr::SolrResponseHash.new({ "response" =>
243
- { "numFound" => 0,
244
- "start" => 0,
245
- "docs" => []
246
- }
247
- })
233
+ })
234
+
235
+ @solr_resp_no_docs = RSpecSolr::SolrResponseHash.new('response' =>
236
+ { 'numFound' => 0,
237
+ 'start' => 0,
238
+ 'docs' => []
239
+ })
248
240
  end
249
-
250
- end
241
+ end
@@ -2,114 +2,107 @@ require 'spec_helper'
2
2
  require 'rspec-solr'
3
3
 
4
4
  describe RSpecSolr::SolrResponseHash do
5
-
6
- context "id field" do
5
+ context 'id field' do
7
6
  before(:all) do
8
- @srh = RSpecSolr::SolrResponseHash.new({ "response" =>
9
- { "docs" =>
10
- [ {"id"=>"111"},
11
- {"not_id"=>"222"},
12
- {"id"=>"333"},
7
+ @srh = RSpecSolr::SolrResponseHash.new('response' =>
8
+ { 'docs' =>
9
+ [{ 'id' => '111' },
10
+ { 'not_id' => '222' },
11
+ { 'id' => '333' }
13
12
  ]
14
- }
15
- })
13
+ })
16
14
  end
17
15
  it "should default to 'id'" do
18
- RSpecSolr::SolrResponseHash.new({}).id_field.should == "id"
19
- @srh.id_field.should == "id"
16
+ expect(RSpecSolr::SolrResponseHash.new({}).id_field).to eq('id')
17
+ expect(@srh.id_field).to eq('id')
20
18
  end
21
- it "should be changable to whatever" do
22
- @srh.id_field='new'
23
- @srh.id_field.should == 'new'
24
- @srh.id_field='newer'
25
- @srh.id_field.should == 'newer'
19
+ it 'should be changable to whatever' do
20
+ @srh.id_field = 'new'
21
+ expect(@srh.id_field).to eq('new')
22
+ @srh.id_field = 'newer'
23
+ expect(@srh.id_field).to eq('newer')
26
24
  end
27
25
  end
28
-
26
+
29
27
  # fixture below
30
-
31
- context "has_document?" do
32
- it "should be true when single document meets expectation" do
33
- @solr_resp_5_docs.should have_document({"id" => "222"})
34
- @solr_resp_5_docs.should have_document({"id" => "111", "fld" => "val"})
35
- end
36
-
37
- it "should be true when at least one doc meets expectation" do
38
- @solr_resp_5_docs.should have_document({"fld" => "val"})
39
- end
40
-
41
- it "should be false when no docs meet expectation" do
42
- @solr_resp_5_docs.should_not have_document({"id" => "not_there"})
43
- end
44
-
45
- it "should be false when only part of expectation is met" do
46
- @solr_resp_5_docs.should_not have_document({"id" => "222", "fld" => "val"})
47
- end
48
-
49
- it "should be true when document is < = expected position in results" do
50
- @solr_resp_5_docs.should have_document({"id" => "222"}, 2)
51
- end
52
-
53
- it "should be false when document is > expected position in results" do
54
- @solr_resp_5_docs.should_not have_document({"id" => "222"}, 1)
55
- end
56
-
28
+
29
+ context 'has_document?' do
30
+ it 'should be true when single document meets expectation' do
31
+ expect(@solr_resp_5_docs).to have_document('id' => '222')
32
+ expect(@solr_resp_5_docs).to have_document('id' => '111', 'fld' => 'val')
33
+ end
34
+
35
+ it 'should be true when at least one doc meets expectation' do
36
+ expect(@solr_resp_5_docs).to have_document('fld' => 'val')
37
+ end
38
+
39
+ it 'should be false when no docs meet expectation' do
40
+ expect(@solr_resp_5_docs).not_to have_document('id' => 'not_there')
41
+ end
42
+
43
+ it 'should be false when only part of expectation is met' do
44
+ expect(@solr_resp_5_docs).not_to have_document('id' => '222', 'fld' => 'val')
45
+ end
46
+
47
+ it 'should be true when document is < = expected position in results' do
48
+ expect(@solr_resp_5_docs).to have_document({ 'id' => '222' }, 2)
49
+ end
50
+
51
+ it 'should be false when document is > expected position in results' do
52
+ expect(@solr_resp_5_docs).not_to have_document({ 'id' => '222' }, 1)
53
+ end
57
54
  end # has_document?
58
-
59
- context "get_first_doc_index" do
60
- it "should get the right document index with an id String argument" do
61
- @solr_resp_5_docs.get_first_doc_index("333").should == 2
62
- @solr_resp_5_docs.get_first_doc_index("111").should == 0
63
- end
64
-
65
- it "should get the first occurrence of a doc meeting a Hash argument" do
66
- @solr_resp_5_docs.get_first_doc_index("fld"=>"val").should == 0
67
- @solr_resp_5_docs.get_first_doc_index("id"=>"333").should == 2
68
- end
69
-
70
- it "should get the index of the doc occurring first in the results from an Array argument" do
71
- @solr_resp_5_docs.get_first_doc_index(["fld"=>"val"]).should == 0
72
- @solr_resp_5_docs.get_first_doc_index(["222", "444"]).should == 1
73
- end
74
-
55
+
56
+ context 'get_first_doc_index' do
57
+ it 'should get the right document index with an id String argument' do
58
+ expect(@solr_resp_5_docs.get_first_doc_index('333')).to eq(2)
59
+ expect(@solr_resp_5_docs.get_first_doc_index('111')).to eq(0)
60
+ end
61
+
62
+ it 'should get the first occurrence of a doc meeting a Hash argument' do
63
+ expect(@solr_resp_5_docs.get_first_doc_index('fld' => 'val')).to eq(0)
64
+ expect(@solr_resp_5_docs.get_first_doc_index('id' => '333')).to eq(2)
65
+ end
66
+
67
+ it 'should get the index of the doc occurring first in the results from an Array argument' do
68
+ expect(@solr_resp_5_docs.get_first_doc_index(['fld' => 'val'])).to eq(0)
69
+ expect(@solr_resp_5_docs.get_first_doc_index(%w(222 444))).to eq(1)
70
+ end
71
+
75
72
  it "should return nil when the expectation argument isn't met" do
76
- @solr_resp_5_docs.get_first_doc_index("666").should be_nil
77
- @solr_resp_5_docs.get_first_doc_index("not_there"=>"not_there").should be_nil
78
- @solr_resp_5_docs.get_first_doc_index(["222", "666"]).should be_nil
73
+ expect(@solr_resp_5_docs.get_first_doc_index('666')).to be_nil
74
+ expect(@solr_resp_5_docs.get_first_doc_index('not_there' => 'not_there')).to be_nil
75
+ expect(@solr_resp_5_docs.get_first_doc_index(%w(222 666))).to be_nil
79
76
  end
80
-
81
77
  end
82
-
83
- context "get_min_index" do
84
- it "should return nil when both arguments are nil" do
85
- @solr_resp_5_docs.send(:get_min_index, nil, nil).should be_nil
78
+
79
+ context 'get_min_index' do
80
+ it 'should return nil when both arguments are nil' do
81
+ expect(@solr_resp_5_docs.send(:get_min_index, nil, nil)).to be_nil
86
82
  end
87
- it "should return the first argument when the second argument is nil" do
88
- @solr_resp_5_docs.send(:get_min_index, 3, nil).should == 3
83
+ it 'should return the first argument when the second argument is nil' do
84
+ expect(@solr_resp_5_docs.send(:get_min_index, 3, nil)).to eq(3)
89
85
  end
90
- it "should return the second argument when the first argument is nil" do
91
- @solr_resp_5_docs.send(:get_min_index, nil, 5).should == 5
86
+ it 'should return the second argument when the first argument is nil' do
87
+ expect(@solr_resp_5_docs.send(:get_min_index, nil, 5)).to eq(5)
88
+ end
89
+ it 'should return the minimum of the two arguments when neither of them is nil' do
90
+ expect(@solr_resp_5_docs.send(:get_min_index, 2, 5)).to eq(2)
91
+ expect(@solr_resp_5_docs.send(:get_min_index, 5, 2)).to eq(2)
92
92
  end
93
- it "should return the minimum of the two arguments when neither of them is nil" do
94
- @solr_resp_5_docs.send(:get_min_index, 2, 5).should == 2
95
- @solr_resp_5_docs.send(:get_min_index, 5, 2).should == 2
96
- end
97
93
  end
98
-
99
-
94
+
100
95
  before(:all) do
101
- @solr_resp_5_docs = RSpecSolr::SolrResponseHash.new({ "response" =>
102
- { "numFound" => 5,
103
- "start" => 0,
104
- "docs" =>
105
- [ {"id"=>"111", "fld"=>"val"},
106
- {"id"=>"222"},
107
- {"id"=>"333", "fld"=>"val"},
108
- {"id"=>"444"},
109
- {"id"=>"555"}
96
+ @solr_resp_5_docs = RSpecSolr::SolrResponseHash.new('response' =>
97
+ { 'numFound' => 5,
98
+ 'start' => 0,
99
+ 'docs' =>
100
+ [{ 'id' => '111', 'fld' => 'val' },
101
+ { 'id' => '222' },
102
+ { 'id' => '333', 'fld' => 'val' },
103
+ { 'id' => '444' },
104
+ { 'id' => '555' }
110
105
  ]
111
- }
112
- })
106
+ })
113
107
  end
114
-
115
- end
108
+ end