rspec-solr 1.0.1 → 2.0.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +53 -0
- data/.travis.yml +1 -3
- data/.yardopts +1 -1
- data/Gemfile +2 -0
- data/MATCHERS.md +168 -0
- data/{README.rdoc → README.md} +31 -26
- data/Rakefile +4 -4
- data/lib/rspec-solr.rb +6 -7
- data/lib/rspec-solr/compare_num_docs_matcher.rb +32 -49
- data/lib/rspec-solr/have_documents_matcher.rb +10 -19
- data/lib/rspec-solr/have_facet_field_matcher.rb +16 -24
- data/lib/rspec-solr/include_documents_matcher.rb +65 -46
- data/lib/rspec-solr/solr_response_hash.rb +52 -55
- data/lib/rspec-solr/version.rb +1 -1
- data/lib/tasks/ci.rake +4 -4
- data/lib/tasks/doc.rake +8 -8
- data/lib/tasks/spec.rake +1 -1
- data/rspec-solr.gemspec +20 -20
- data/spec/comparing_num_docs_in_2_resp_spec.rb +205 -217
- data/spec/have_documents_spec.rb +37 -39
- data/spec/have_facet_field_spec.rb +69 -74
- data/spec/include_before_spec.rb +69 -77
- data/spec/include_document_spec.rb +317 -340
- data/spec/include_in_each_of_first_n_spec.rb +76 -79
- data/spec/include_in_first_n_spec.rb +188 -192
- data/spec/number_of_documents_spec.rb +192 -201
- data/spec/solr_response_hash_spec.rb +85 -92
- data/spec/spec_helper.rb +5 -16
- metadata +44 -31
- data/MATCHERS.rdoc +0 -169
- data/spec/support/matchers.rb +0 -22
data/spec/have_documents_spec.rb
CHANGED
@@ -2,59 +2,57 @@ require 'spec_helper'
|
|
2
2
|
require 'rspec-solr'
|
3
3
|
|
4
4
|
describe RSpecSolr do
|
5
|
-
|
6
5
|
# fixtures below
|
7
6
|
|
8
|
-
context
|
9
|
-
it
|
10
|
-
@solr_resp_w_docs.
|
11
|
-
@solr_resp_total_but_no_docs.
|
7
|
+
context 'have_documents with no doc matcher' do
|
8
|
+
it 'passes if response.should has documents' do
|
9
|
+
expect(@solr_resp_w_docs).to have_documents
|
10
|
+
expect(@solr_resp_total_but_no_docs).to have_documents
|
12
11
|
end
|
13
12
|
|
14
|
-
it
|
15
|
-
@solr_resp_no_docs.
|
13
|
+
it 'passes if response.should_not has no documents' do
|
14
|
+
expect(@solr_resp_no_docs).not_to have_documents
|
16
15
|
end
|
17
16
|
|
18
|
-
it
|
19
|
-
|
20
|
-
@solr_resp_no_docs.
|
21
|
-
|
17
|
+
it 'failure message for should' do
|
18
|
+
expect do
|
19
|
+
expect(@solr_resp_no_docs).to have_documents
|
20
|
+
end.to raise_error.with_message a_string_including 'expected documents in Solr response '
|
22
21
|
end
|
23
22
|
|
24
|
-
it
|
25
|
-
|
26
|
-
@solr_resp_w_docs.
|
27
|
-
@solr_resp_total_but_no_docs.
|
28
|
-
|
29
|
-
end
|
23
|
+
it 'failure message for should_not' do
|
24
|
+
expect do
|
25
|
+
expect(@solr_resp_w_docs).not_to have_documents
|
26
|
+
expect(@solr_resp_total_but_no_docs).not_to have_documents
|
27
|
+
end.to raise_error.with_message a_string_including 'did not expect documents, but Solr response had '
|
28
|
+
end
|
30
29
|
end
|
31
|
-
|
30
|
+
|
32
31
|
before(:all) do
|
33
|
-
@solr_resp_w_docs = {
|
34
|
-
{
|
35
|
-
|
36
|
-
|
37
|
-
[
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
@solr_resp_w_docs = { 'response' =>
|
33
|
+
{ 'numFound' => 5,
|
34
|
+
'start' => 0,
|
35
|
+
'docs' =>
|
36
|
+
[{ 'id' => '111' },
|
37
|
+
{ 'id' => '222' },
|
38
|
+
{ 'id' => '333' },
|
39
|
+
{ 'id' => '444' },
|
40
|
+
{ 'id' => '555' }
|
42
41
|
]
|
43
42
|
}
|
44
43
|
}
|
45
44
|
|
46
|
-
@solr_resp_no_docs = {
|
47
|
-
{
|
48
|
-
|
49
|
-
|
45
|
+
@solr_resp_no_docs = { 'response' =>
|
46
|
+
{ 'numFound' => 0,
|
47
|
+
'start' => 0,
|
48
|
+
'docs' => []
|
50
49
|
}
|
51
|
-
}
|
52
|
-
@solr_resp_total_but_no_docs = {
|
53
|
-
{
|
54
|
-
|
55
|
-
|
50
|
+
}
|
51
|
+
@solr_resp_total_but_no_docs = { 'response' =>
|
52
|
+
{ 'numFound' => 1324,
|
53
|
+
'start' => 0,
|
54
|
+
'docs' => []
|
56
55
|
}
|
57
|
-
}
|
56
|
+
}
|
58
57
|
end
|
59
|
-
|
60
|
-
end
|
58
|
+
end
|
@@ -2,100 +2,95 @@ require 'spec_helper'
|
|
2
2
|
require 'rspec-solr'
|
3
3
|
|
4
4
|
describe RSpecSolr do
|
5
|
-
|
6
5
|
# fixtures below
|
7
|
-
context
|
8
|
-
it
|
9
|
-
@solr_resp_w_facets.
|
10
|
-
@solr_resp_w_facets.
|
6
|
+
context 'should have_facet_field()' do
|
7
|
+
it 'passes if response has the facet field' do
|
8
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff1')
|
9
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff2')
|
11
10
|
end
|
12
|
-
it
|
13
|
-
@solr_resp_w_facets.
|
11
|
+
it 'passes if response has facet field but no values' do
|
12
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff3')
|
14
13
|
end
|
15
|
-
it
|
16
|
-
|
17
|
-
@solr_resp_w_facets.
|
18
|
-
|
14
|
+
it 'fails if response does not have the facet field' do
|
15
|
+
expect do
|
16
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff4')
|
17
|
+
end.to raise_error.with_message a_string_including 'expected facet field ff4 with values in Solr response: '
|
19
18
|
end
|
20
19
|
end
|
21
|
-
|
22
|
-
context
|
23
|
-
it
|
24
|
-
|
25
|
-
@solr_resp_w_facets.
|
26
|
-
|
27
|
-
|
28
|
-
@solr_resp_w_facets.
|
29
|
-
|
20
|
+
|
21
|
+
context 'should_NOT have_facet_field()' do
|
22
|
+
it 'fails if response has the facet field' do
|
23
|
+
expect do
|
24
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff1')
|
25
|
+
end.to raise_error.with_message a_string_including 'expected no ff1 facet field in Solr response: '
|
26
|
+
expect do
|
27
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff2')
|
28
|
+
end.to raise_error.with_message a_string_including 'expected no ff2 facet field in Solr response: '
|
30
29
|
end
|
31
|
-
it
|
32
|
-
|
33
|
-
@solr_resp_w_facets.
|
34
|
-
|
30
|
+
it 'fails if response has facet field but no values' do
|
31
|
+
expect do
|
32
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff3')
|
33
|
+
end.to raise_error.with_message a_string_including 'expected no ff3 facet field in Solr response: '
|
35
34
|
end
|
36
|
-
it
|
37
|
-
@solr_resp_w_facets.
|
35
|
+
it 'passes if response does not have the facet field' do
|
36
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff4')
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
context
|
42
|
-
it
|
43
|
-
@solr_resp_w_facets.
|
40
|
+
context 'should have_facet_field().with_value()' do
|
41
|
+
it 'passes if response has the facet field with the value' do
|
42
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff1').with_value('val12')
|
44
43
|
end
|
45
|
-
it
|
46
|
-
|
47
|
-
@solr_resp_w_facets.
|
48
|
-
|
44
|
+
it 'fails if response has the facet field without the value' do
|
45
|
+
expect do
|
46
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff1').with_value('val22')
|
47
|
+
end.to raise_error.with_message a_string_including 'expected facet field ff1 with value val22 in Solr response'
|
49
48
|
end
|
50
|
-
it
|
51
|
-
|
52
|
-
@solr_resp_w_facets.
|
53
|
-
|
49
|
+
it 'fails if response has facet field but no values' do
|
50
|
+
expect do
|
51
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff3').with_value('val')
|
52
|
+
end.to raise_error.with_message a_string_including 'expected facet field ff3 with value val in Solr response'
|
54
53
|
end
|
55
|
-
it
|
56
|
-
|
57
|
-
@solr_resp_w_facets.
|
58
|
-
|
54
|
+
it 'fails if response does not have the facet field' do
|
55
|
+
expect do
|
56
|
+
expect(@solr_resp_w_facets).to have_facet_field('ff4').with_value('val')
|
57
|
+
end.to raise_error.with_message a_string_including 'expected facet field ff4 with value val in Solr response'
|
59
58
|
end
|
60
|
-
|
61
59
|
end
|
62
|
-
context
|
63
|
-
it
|
64
|
-
|
65
|
-
@solr_resp_w_facets.
|
66
|
-
|
60
|
+
context 'should_NOT have_facet_field().with_value()' do
|
61
|
+
it 'fails if response has the facet field with the value' do
|
62
|
+
expect do
|
63
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff1').with_value('val12')
|
64
|
+
end.to raise_error.with_message a_string_including 'expected facet field ff1 not to have value val12 in Solr response'
|
67
65
|
end
|
68
|
-
it
|
69
|
-
@solr_resp_w_facets.
|
66
|
+
it 'passes if response has the facet field without the value' do
|
67
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff1').with_value('val22')
|
70
68
|
end
|
71
|
-
it
|
72
|
-
@solr_resp_w_facets.
|
69
|
+
it 'passes if response has facet field but no values' do
|
70
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff3').with_value('val')
|
73
71
|
end
|
74
|
-
it
|
75
|
-
|
76
|
-
@solr_resp_w_facets.
|
77
|
-
|
72
|
+
it 'fails if response does not have the facet field' do
|
73
|
+
expect do
|
74
|
+
expect(@solr_resp_w_facets).not_to have_facet_field('ff4').with_value('val')
|
75
|
+
end.to raise_error.with_message a_string_including 'expected facet field ff4 in Solr response'
|
78
76
|
end
|
79
77
|
end
|
80
|
-
|
81
|
-
|
78
|
+
|
82
79
|
before(:all) do
|
83
80
|
@solr_resp_w_facets = RSpecSolr::SolrResponseHash.new(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
})
|
81
|
+
'response' =>
|
82
|
+
{ 'numFound' => 5,
|
83
|
+
'start' => 0,
|
84
|
+
'docs' => [] },
|
85
|
+
'facet_counts' =>
|
86
|
+
{ 'facet_queries' => {},
|
87
|
+
'facet_fields' => {
|
88
|
+
'ff1' => ['val11', 111, 'val12', 22, 'val13', 3],
|
89
|
+
'ff2' => ['val21', 10, 'val22', 5, 'val23', 1],
|
90
|
+
'ff3' => []
|
91
|
+
},
|
92
|
+
'facet_dates' => {},
|
93
|
+
'facet_ranges' => {}
|
94
|
+
})
|
99
95
|
end
|
100
|
-
|
101
|
-
end
|
96
|
+
end
|
data/spec/include_before_spec.rb
CHANGED
@@ -2,106 +2,98 @@ require 'spec_helper'
|
|
2
2
|
require 'rspec-solr'
|
3
3
|
|
4
4
|
describe RSpecSolr do
|
5
|
-
|
6
5
|
# fixtures below
|
7
|
-
|
8
|
-
context
|
9
|
-
|
10
|
-
|
11
|
-
@solr_resp_5_docs.
|
12
|
-
@solr_resp_5_docs.
|
13
|
-
@solr_resp_5_docs.
|
14
|
-
@solr_resp_5_docs.
|
15
|
-
@solr_resp_5_docs.should include([{"id"=>"111"}, {"id"=>"333"}]).before([{"id"=>"444"}, {"id"=>"555"}])
|
6
|
+
|
7
|
+
context 'should include().before()' do
|
8
|
+
it 'passes when criteria are met' do
|
9
|
+
expect(@solr_resp_5_docs).to include('111').before('222')
|
10
|
+
expect(@solr_resp_5_docs).to include('333').before('fld' => %w(val1 val2 val3))
|
11
|
+
expect(@solr_resp_5_docs).to include('fld' => 'val').before('fld' => %w(val1 val2 val3))
|
12
|
+
expect(@solr_resp_5_docs).to include(%w(111 222)).before(%w(333 555))
|
13
|
+
expect(@solr_resp_5_docs).to include([{ 'id' => '111' }, { 'id' => '333' }]).before([{ 'id' => '444' }, { 'id' => '555' }])
|
16
14
|
end
|
17
|
-
it
|
18
|
-
@solr_resp_5_docs.
|
15
|
+
it 'passes when criteria CAN BE met (more than one option)' do
|
16
|
+
expect(@solr_resp_5_docs).to include('111').before('fld' => 'val')
|
19
17
|
end
|
20
18
|
it "fails when docs aren't in expected order" do
|
21
|
-
|
22
|
-
@solr_resp_5_docs.
|
23
|
-
|
24
|
-
|
25
|
-
@solr_resp_5_docs.
|
26
|
-
|
27
|
-
|
28
|
-
@solr_resp_5_docs.
|
29
|
-
|
19
|
+
expect do
|
20
|
+
expect(@solr_resp_5_docs).to include('222').before('fld2' => 'val2')
|
21
|
+
end.to raise_error.with_message a_string_including 'expected response to include document "222" before document matching {"fld2"=>"val2"}'
|
22
|
+
expect do
|
23
|
+
expect(@solr_resp_5_docs).to include('111', '444').before([{ 'id' => '333' }, { 'id' => '555' }])
|
24
|
+
end.to raise_error.with_message a_string_including 'expected response to include documents "111" and "444" before documents matching [{"id"=>"333"}, {"id"=>"555"}]'
|
25
|
+
expect do
|
26
|
+
expect(@solr_resp_5_docs).to include([{ 'id' => '222' }, { 'id' => '444' }]).before([{ 'id' => '333' }, { 'id' => '555' }])
|
27
|
+
end.to raise_error.with_message a_string_including 'expected response to include documents [{"id"=>"222"}, {"id"=>"444"}] before documents matching [{"id"=>"333"}, {"id"=>"555"}]'
|
30
28
|
end
|
31
29
|
it "fails when it can't find a doc matching first argument(s)" do
|
32
|
-
|
33
|
-
@solr_resp_5_docs.
|
34
|
-
|
30
|
+
expect do
|
31
|
+
expect(@solr_resp_5_docs).to include('not_there').before('555')
|
32
|
+
end.to raise_error.with_message a_string_including 'expected response to include document "not_there" before document matching "555"'
|
35
33
|
end
|
36
34
|
it "fails when it can't find a doc matching second argument(s)" do
|
37
|
-
|
38
|
-
@solr_resp_5_docs.
|
39
|
-
|
35
|
+
expect do
|
36
|
+
expect(@solr_resp_5_docs).to include('222').before('not_there')
|
37
|
+
end.to raise_error.with_message a_string_including 'expected response to include document "222" before document matching "not_there"'
|
40
38
|
end
|
41
39
|
it "fails when it can't find docs matching first or second argument(s)" do
|
42
|
-
|
43
|
-
@solr_resp_5_docs.
|
44
|
-
|
40
|
+
expect do
|
41
|
+
expect(@solr_resp_5_docs).to include('not_there').before('still_not_there')
|
42
|
+
end.to raise_error.with_message a_string_including 'expected response to include document "not_there" before document matching "still_not_there"'
|
45
43
|
end
|
46
|
-
|
47
44
|
end # should include().before()
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@solr_resp_5_docs.should_not include([{"id"=>"111"}, {"id"=>"333"}]).before([{"id"=>"444"}, {"id"=>"555"}])
|
67
|
-
}.should fail_matching('not to include documents [{"id"=>"111"}, {"id"=>"333"}] before documents matching [{"id"=>"444"}, {"id"=>"555"}]')
|
45
|
+
|
46
|
+
context 'should_NOT include().before()' do
|
47
|
+
it 'fails when criteria are met' do
|
48
|
+
expect do
|
49
|
+
expect(@solr_resp_5_docs).not_to include('111').before('222')
|
50
|
+
end.to raise_error.with_message a_string_including 'not to include document "111" before document matching "222"'
|
51
|
+
expect do
|
52
|
+
expect(@solr_resp_5_docs).not_to include('333').before('fld' => %w(val1 val2 val3))
|
53
|
+
end.to raise_error.with_message a_string_including 'not to include document "333" before document matching {"fld"=>["val1", "val2", "val3"]}'
|
54
|
+
expect do
|
55
|
+
expect(@solr_resp_5_docs).not_to include('fld' => 'val').before('fld' => %w(val1 val2 val3))
|
56
|
+
end.to raise_error.with_message a_string_including 'not to include document {"fld"=>"val"} before document matching {"fld"=>["val1", "val2", "val3"]}'
|
57
|
+
expect do
|
58
|
+
expect(@solr_resp_5_docs).not_to include(%w(111 222)).before(%w(333 555))
|
59
|
+
end.to raise_error.with_message a_string_including 'not to include documents ["111", "222"] before documents matching ["333", "555"]'
|
60
|
+
expect do
|
61
|
+
expect(@solr_resp_5_docs).not_to include([{ 'id' => '111' }, { 'id' => '333' }]).before([{ 'id' => '444' }, { 'id' => '555' }])
|
62
|
+
end.to raise_error.with_message a_string_including 'not to include documents [{"id"=>"111"}, {"id"=>"333"}] before documents matching [{"id"=>"444"}, {"id"=>"555"}]'
|
68
63
|
end
|
69
|
-
it
|
70
|
-
|
71
|
-
@solr_resp_5_docs.
|
72
|
-
|
64
|
+
it 'fails when criteria CAN BE met (more than one option)' do
|
65
|
+
expect do
|
66
|
+
expect(@solr_resp_5_docs).not_to include('111').before('fld' => 'val')
|
67
|
+
end.to raise_error.with_message a_string_including 'not to include document "111" before document matching {"fld"=>"val"}'
|
73
68
|
end
|
74
69
|
it "passes when docs aren't in expected order" do
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
expect(@solr_resp_5_docs).not_to include('222').before('fld2' => 'val2')
|
71
|
+
# NOTE: it is picky about the next line include() being ["111", "444"], not just "111", "444"
|
72
|
+
expect(@solr_resp_5_docs).not_to include(%w(111 444)).before([{ 'id' => '333' }, { 'id' => '555' }])
|
73
|
+
expect(@solr_resp_5_docs).not_to include([{ 'id' => '222' }, { 'id' => '444' }]).before([{ 'id' => '333' }, { 'id' => '555' }])
|
79
74
|
end
|
80
75
|
it "passes when it can't find a doc matching first argument(s)" do
|
81
|
-
@solr_resp_5_docs.
|
76
|
+
expect(@solr_resp_5_docs).not_to include('not_there').before('555')
|
82
77
|
end
|
83
78
|
it "passes when it can't find a doc matching second argument(s)" do
|
84
|
-
@solr_resp_5_docs.
|
79
|
+
expect(@solr_resp_5_docs).not_to include('222').before('not_there')
|
85
80
|
end
|
86
81
|
it "passes when it can't find docs matching first or second argument(s)" do
|
87
|
-
@solr_resp_5_docs.
|
82
|
+
expect(@solr_resp_5_docs).not_to include('not_there').before('still_not_there')
|
88
83
|
end
|
89
|
-
|
90
84
|
end # should_NOT include().before()
|
91
|
-
|
85
|
+
|
92
86
|
before(:all) do
|
93
|
-
@solr_resp_5_docs = RSpecSolr::SolrResponseHash.new(
|
94
|
-
{
|
95
|
-
|
96
|
-
|
97
|
-
[
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
87
|
+
@solr_resp_5_docs = RSpecSolr::SolrResponseHash.new('response' =>
|
88
|
+
{ 'numFound' => 5,
|
89
|
+
'start' => 0,
|
90
|
+
'docs' =>
|
91
|
+
[{ 'id' => '111', 'fld' => 'val', 'fld2' => 'val2' },
|
92
|
+
{ 'id' => '222' },
|
93
|
+
{ 'id' => '333', 'fld' => 'val' },
|
94
|
+
{ 'id' => '444', 'fld' => %w(val1 val2 val3) },
|
95
|
+
{ 'id' => '555' }
|
102
96
|
]
|
103
|
-
}
|
104
|
-
})
|
97
|
+
})
|
105
98
|
end
|
106
|
-
|
107
|
-
end
|
99
|
+
end
|
@@ -2,457 +2,434 @@ require 'spec_helper'
|
|
2
2
|
require 'rspec-solr'
|
3
3
|
|
4
4
|
describe RSpecSolr do
|
5
|
-
|
6
5
|
# fixtures below
|
7
|
-
|
8
|
-
context "RSpecSolr::SolrResponseHash #include matcher" do
|
9
|
-
|
10
|
-
context "should include('fldname'=>'fldval')" do
|
11
6
|
|
7
|
+
context 'RSpecSolr::SolrResponseHash #include matcher' do
|
8
|
+
context "should include('fldname'=>'fldval')" do
|
12
9
|
it "passes if Solr document in response contains 'fldval' in named field" do
|
13
|
-
@solr_resp_5_docs.
|
14
|
-
@solr_resp_5_docs.
|
10
|
+
expect(@solr_resp_5_docs).to include('id' => '111')
|
11
|
+
expect(@solr_resp_5_docs).to include('fld' => 'val') # 2 docs match
|
15
12
|
end
|
16
|
-
it
|
17
|
-
@solr_resp_5_docs.
|
13
|
+
it 'passes if single value expectation is expressed as an Array' do
|
14
|
+
expect(@solr_resp_5_docs).to include('id' => ['111'])
|
18
15
|
end
|
19
16
|
it "fails if no Solr document in response has 'fldval' for the named field" do
|
20
|
-
|
21
|
-
@solr_resp_5_docs.
|
22
|
-
|
17
|
+
expect do
|
18
|
+
expect(@solr_resp_5_docs).to include('id' => 'not_there')
|
19
|
+
end.to raise_error.with_message a_string_including '} to include {"id" => "not_there"}'
|
23
20
|
end
|
24
|
-
it
|
25
|
-
|
26
|
-
@solr_resp_5_docs.
|
27
|
-
|
21
|
+
it 'fails if no Solr document in response has the named field' do
|
22
|
+
expect do
|
23
|
+
expect(@solr_resp_5_docs).to include('not_there' => 'anything')
|
24
|
+
end.to raise_error.with_message a_string_including '} to include {"not_there" => "anything"}'
|
28
25
|
end
|
29
26
|
end # "should include('fldname'=>'fldval')"
|
30
27
|
|
31
28
|
context "should_NOT include('fldname'=>'fldval')" do
|
32
|
-
|
33
29
|
it "fails if Solr document in response contains 'fldval' in named field" do
|
34
|
-
|
35
|
-
@solr_resp_5_docs.
|
36
|
-
|
37
|
-
|
38
|
-
@solr_resp_5_docs.
|
39
|
-
|
30
|
+
expect do
|
31
|
+
expect(@solr_resp_5_docs).not_to include('id' => '111')
|
32
|
+
end.to raise_error.with_message a_string_including 'not to include {"id" => "111"}'
|
33
|
+
expect do
|
34
|
+
expect(@solr_resp_5_docs).not_to include('fld' => 'val')
|
35
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => "val"}'
|
40
36
|
end
|
41
37
|
it "passes if no Solr document in response has 'fldval' for the named field" do
|
42
|
-
|
38
|
+
expect(@solr_resp_5_docs).not_to include('id' => 'not_there')
|
43
39
|
end
|
44
|
-
it
|
45
|
-
|
40
|
+
it 'passes if no Solr document in response has the named field' do
|
41
|
+
expect(@solr_resp_5_docs).not_to include('not_there' => 'anything')
|
46
42
|
end
|
47
|
-
it
|
48
|
-
@solr_resp_5_docs.
|
43
|
+
it 'passes if single field value is expressed as Array' do
|
44
|
+
expect(@solr_resp_5_docs).not_to include('id' => ['not_there'])
|
49
45
|
end
|
50
46
|
end # "should_not include('fldname'=>'fldval')"
|
51
47
|
|
52
48
|
context "should include('fld1'=>'val1', 'fld2'=>'val2')" do
|
53
|
-
|
54
|
-
|
55
|
-
@solr_resp_5_docs.
|
56
|
-
@solr_resp_5_docs.should include("id" => "333", "fld" => "val")
|
49
|
+
it 'passes if all pairs are included in a Solr document in the response' do
|
50
|
+
expect(@solr_resp_5_docs).to include('id' => '111', 'fld' => 'val')
|
51
|
+
expect(@solr_resp_5_docs).to include('id' => '333', 'fld' => 'val')
|
57
52
|
end
|
58
|
-
it
|
59
|
-
|
60
|
-
@solr_resp_5_docs.
|
61
|
-
|
62
|
-
|
63
|
-
@solr_resp_5_docs.
|
64
|
-
|
65
|
-
|
66
|
-
@solr_resp_5_docs.
|
67
|
-
|
53
|
+
it 'fails if only part of expectation is met' do
|
54
|
+
expect do
|
55
|
+
expect(@solr_resp_5_docs).to include('id' => '111', 'fld' => 'not_there')
|
56
|
+
end.to raise_error.with_message a_string_including '} to include {"id" => "111", "fld" => "not_there"}'
|
57
|
+
expect do
|
58
|
+
expect(@solr_resp_5_docs).to include('id' => '111', 'not_there' => 'whatever')
|
59
|
+
end.to raise_error.with_message a_string_including '} to include {"id" => "111", "not_there" => "whatever"}'
|
60
|
+
expect do
|
61
|
+
expect(@solr_resp_5_docs).to include('id' => '222', 'fld' => 'val')
|
62
|
+
end.to raise_error.with_message a_string_including '} to include {"id" => "222", "fld" => "val"}'
|
68
63
|
end
|
69
|
-
it
|
70
|
-
|
71
|
-
@solr_resp_5_docs.
|
72
|
-
|
64
|
+
it 'fails if no part of expectation is met' do
|
65
|
+
expect do
|
66
|
+
expect(@solr_resp_5_docs).to include('id' => 'not_there', 'not_there' => 'anything')
|
67
|
+
end.to raise_error.with_message a_string_including '} to include {"id" => "not_there", "not_there" => "anything"}'
|
73
68
|
end
|
74
69
|
end # should include('fld1'=>'val1', 'fld2'=>'val2')
|
75
70
|
|
76
71
|
context "should_NOT include('fld1'=>'val1', 'fld2'=>'val2')" do
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}.should fail_matching('not to include {"id"=>"333", "fld"=>"val"}')
|
72
|
+
it 'fails if a Solr document in the response contains all the key/value pairs' do
|
73
|
+
expect do
|
74
|
+
expect(@solr_resp_5_docs).not_to include('id' => '333', 'fld' => 'val')
|
75
|
+
end.to raise_error.with_message a_string_including 'not to include {"id" => "333", "fld" => "val"}'
|
82
76
|
end
|
83
|
-
it
|
84
|
-
|
85
|
-
@solr_resp_5_docs.
|
86
|
-
|
77
|
+
it 'passes if a Solr document in the response contains all the key/value pairs among others' do
|
78
|
+
expect do
|
79
|
+
expect(@solr_resp_5_docs).not_to include('id' => '111', 'fld' => 'val')
|
80
|
+
end.to raise_error.with_message a_string_including 'not to include {"id" => "111", "fld" => "val"}'
|
87
81
|
end
|
88
|
-
it
|
89
|
-
@solr_resp_5_docs.
|
90
|
-
@solr_resp_5_docs.
|
91
|
-
@solr_resp_5_docs.
|
82
|
+
it 'passes if part of the expectation is not met' do
|
83
|
+
expect(@solr_resp_5_docs).not_to include('id' => '111', 'fld' => 'not_there')
|
84
|
+
expect(@solr_resp_5_docs).not_to include('id' => '111', 'not_there' => 'whatever')
|
85
|
+
expect(@solr_resp_5_docs).not_to include('id' => '222', 'fld' => 'val')
|
92
86
|
end
|
93
|
-
it
|
94
|
-
@solr_resp_5_docs.
|
87
|
+
it 'passes if no part of the expectatio is met' do
|
88
|
+
expect(@solr_resp_5_docs).not_to include('id' => 'not_there', 'not_there' => 'anything')
|
95
89
|
end
|
96
|
-
end # should_not include('fld1'=>'val1', 'fld2'=>'val2')
|
97
|
-
|
98
|
-
context
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
@solr_resp_5_docs.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
@solr_resp_5_docs.
|
107
|
-
@solr_resp_5_docs.
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}.should fail_matching('} to include {"fld"=>["val1", "val2", "not_there"]}')
|
90
|
+
end # should_not include('fld1'=>'val1', 'fld2'=>'val2')
|
91
|
+
|
92
|
+
context 'multi-valued fields and expectations' do
|
93
|
+
context 'should include(doc_exp)' do
|
94
|
+
it 'passes if all the expected values match all the values in a Solr document in the response' do
|
95
|
+
expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3))
|
96
|
+
expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3), 'id' => '444')
|
97
|
+
end
|
98
|
+
it 'passes if all the expected values match some of the values in a Solr document in the response' do
|
99
|
+
expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2))
|
100
|
+
expect(@solr_resp_5_docs).to include('fld' => 'val1')
|
101
|
+
expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2), 'id' => '444')
|
102
|
+
end
|
103
|
+
it 'fails if none of the expected values match the values in a Solr document in the response' do
|
104
|
+
expect do
|
105
|
+
expect(@solr_resp_5_docs).to include('fld' => %w(not_there also_not_there))
|
106
|
+
end.to raise_error.with_message a_string_including '} to include {"fld" => ["not_there", "also_not_there"]}'
|
107
|
+
end
|
108
|
+
it 'fails if only some of the expected values match the values in a Solr document in the response' do
|
109
|
+
expect do
|
110
|
+
expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 not_there))
|
111
|
+
end.to raise_error.with_message a_string_including '} to include {"fld" => ["val1", "val2", "not_there"]}'
|
119
112
|
end
|
120
113
|
end # should
|
121
|
-
|
122
|
-
context
|
123
|
-
it
|
124
|
-
|
125
|
-
@solr_resp_5_docs.
|
126
|
-
|
127
|
-
|
128
|
-
@solr_resp_5_docs.
|
129
|
-
|
130
|
-
end
|
131
|
-
it
|
132
|
-
|
133
|
-
@solr_resp_5_docs.
|
134
|
-
|
135
|
-
|
136
|
-
@solr_resp_5_docs.
|
137
|
-
|
138
|
-
|
139
|
-
@solr_resp_5_docs.
|
140
|
-
|
141
|
-
end
|
142
|
-
it
|
143
|
-
@solr_resp_5_docs.
|
144
|
-
@solr_resp_5_docs.
|
145
|
-
end
|
146
|
-
it
|
147
|
-
@solr_resp_5_docs.
|
148
|
-
@solr_resp_5_docs.
|
149
|
-
end
|
150
|
-
end # should_not
|
151
|
-
|
114
|
+
|
115
|
+
context 'should_NOT include(doc_exp)' do
|
116
|
+
it 'fails if all the expected values match all the values in a Solr document in the response' do
|
117
|
+
expect do
|
118
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3))
|
119
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => ["val1", "val2", "val3"]}'
|
120
|
+
expect do
|
121
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3), 'id' => '444')
|
122
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => ["val1", "val2", "val3"], "id" => "444"}'
|
123
|
+
end
|
124
|
+
it 'fails if all the expected values match some of the values in a Solr document in the response' do
|
125
|
+
expect do
|
126
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2))
|
127
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => ["val1", "val2"]}'
|
128
|
+
expect do
|
129
|
+
expect(@solr_resp_5_docs).not_to include('fld' => 'val1')
|
130
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => "val1"}'
|
131
|
+
expect do
|
132
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2), 'id' => '444')
|
133
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => ["val1", "val2"], "id" => "444"}'
|
134
|
+
end
|
135
|
+
it 'passes if none of the expected values match the values in a Solr document in the response' do
|
136
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(not_there also_not_there))
|
137
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(not_there also_not_there), 'id' => '444')
|
138
|
+
end
|
139
|
+
it 'passes if only some of the expected values match the values in a Solr document in the response' do
|
140
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 not_there))
|
141
|
+
expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 not_there), 'id' => '444')
|
142
|
+
end
|
143
|
+
end # should_not
|
152
144
|
end # multi-valued fields in docs
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
end
|
161
|
-
it "passes if string matches non-default id_field in the SolrResponseHash object" do
|
145
|
+
|
146
|
+
context 'single String argument' do
|
147
|
+
context 'should include(single_string_arg)' do
|
148
|
+
it 'passes if string matches default id_field of Solr document in the response' do
|
149
|
+
expect(@solr_resp_5_docs).to include('111')
|
150
|
+
end
|
151
|
+
it 'passes if string matches non-default id_field in the SolrResponseHash object' do
|
162
152
|
my_srh = @solr_resp_5_docs.clone
|
163
|
-
my_srh.id_field='fld2'
|
164
|
-
my_srh.
|
153
|
+
my_srh.id_field = 'fld2'
|
154
|
+
expect(my_srh).to include('val2')
|
165
155
|
end
|
166
|
-
it
|
167
|
-
|
168
|
-
@solr_resp_5_docs.
|
169
|
-
|
156
|
+
it 'fails if string does not match default id_field of Solr document in the response' do
|
157
|
+
expect do
|
158
|
+
expect(@solr_resp_5_docs).to include('666')
|
159
|
+
end.to raise_error.with_message a_string_including '} to include "666"'
|
170
160
|
end
|
171
161
|
it "fails if string doesn't match non-default id_field in the SolrResponseHash object" do
|
172
162
|
my_srh = @solr_resp_5_docs.clone
|
173
|
-
my_srh.id_field='fld2'
|
174
|
-
|
175
|
-
my_srh.
|
176
|
-
|
177
|
-
end
|
163
|
+
my_srh.id_field = 'fld2'
|
164
|
+
expect do
|
165
|
+
expect(my_srh).to include('val')
|
166
|
+
end.to raise_error.with_message a_string_including '} to include "val"'
|
167
|
+
end
|
178
168
|
end # should
|
179
169
|
|
180
|
-
context
|
181
|
-
it
|
182
|
-
|
183
|
-
@solr_resp_5_docs.
|
184
|
-
|
170
|
+
context 'should_NOT include(single_string_arg)' do
|
171
|
+
it 'fails if string matches default id_field of Solr document in the response' do
|
172
|
+
expect do
|
173
|
+
expect(@solr_resp_5_docs).not_to include('111')
|
174
|
+
end.to raise_error.with_message a_string_including 'not to include "111"'
|
185
175
|
end
|
186
|
-
it
|
176
|
+
it 'fails if string matches non-default id_field in the SolrResponseHash object' do
|
187
177
|
my_srh = @solr_resp_5_docs.clone
|
188
|
-
my_srh.id_field='fld2'
|
189
|
-
|
190
|
-
my_srh.
|
191
|
-
|
178
|
+
my_srh.id_field = 'fld2'
|
179
|
+
expect do
|
180
|
+
expect(my_srh).not_to include('val2')
|
181
|
+
end.to raise_error.with_message a_string_including 'not to include "val2"'
|
192
182
|
end
|
193
|
-
it
|
194
|
-
@solr_resp_5_docs.
|
183
|
+
it 'passes if string does not match default id_field of Solr document in the response' do
|
184
|
+
expect(@solr_resp_5_docs).not_to include('666')
|
195
185
|
end
|
196
186
|
it "fails if string doesn't match non-default id_field in the SolrResponseHash object" do
|
197
187
|
my_srh = @solr_resp_5_docs.clone
|
198
|
-
my_srh.id_field='fld2'
|
199
|
-
my_srh.
|
200
|
-
end
|
188
|
+
my_srh.id_field = 'fld2'
|
189
|
+
expect(my_srh).not_to include('val')
|
190
|
+
end
|
201
191
|
end # should_not
|
202
|
-
|
203
192
|
end # single String arg
|
204
193
|
|
205
|
-
context
|
206
|
-
|
207
|
-
context "should include(Array_of_Strings)" do
|
194
|
+
context 'Array argument' do
|
195
|
+
context 'should include(Array_of_Strings)' do
|
208
196
|
it "passes if all Strings in Array match all Solr documents' id_field in the response" do
|
209
|
-
@solr_resp_5_docs.
|
197
|
+
expect(@solr_resp_5_docs).to include(%w(111 222 333 444 555))
|
210
198
|
my_srh = @solr_resp_5_docs.clone
|
211
|
-
my_srh.id_field='fld2'
|
212
|
-
my_srh.
|
199
|
+
my_srh.id_field = 'fld2'
|
200
|
+
expect(my_srh).to include(['val2'])
|
213
201
|
end
|
214
202
|
it "passes if all Strings in Array match some Solr documents' id_field in the response" do
|
215
|
-
@solr_resp_5_docs.
|
216
|
-
@solr_resp_5_docs.
|
203
|
+
expect(@solr_resp_5_docs).to include(%w(111 222 333))
|
204
|
+
expect(@solr_resp_5_docs).to include(['111'])
|
217
205
|
my_srh = @solr_resp_5_docs.clone
|
218
|
-
my_srh.id_field='fld'
|
219
|
-
my_srh.
|
206
|
+
my_srh.id_field = 'fld'
|
207
|
+
expect(my_srh).to include(['val'])
|
220
208
|
end
|
221
209
|
it "fails if no Strings in Array match Solr documents' id_field in the response" do
|
222
|
-
|
223
|
-
@solr_resp_5_docs.
|
224
|
-
|
210
|
+
expect do
|
211
|
+
expect(@solr_resp_5_docs).to include(%w(888 899))
|
212
|
+
end.to raise_error.with_message a_string_including '} to include ["888", "899"]'
|
225
213
|
my_srh = @solr_resp_5_docs.clone
|
226
|
-
my_srh.id_field='fld2'
|
227
|
-
|
228
|
-
my_srh.
|
229
|
-
|
214
|
+
my_srh.id_field = 'fld2'
|
215
|
+
expect do
|
216
|
+
expect(my_srh).to include(%w(val8 val9))
|
217
|
+
end.to raise_error.with_message a_string_including '} to include ["val8", "val9"]'
|
230
218
|
end
|
231
219
|
it "fails if only some Strings in Array match Solr documents' id_field in the response" do
|
232
|
-
|
233
|
-
@solr_resp_5_docs.
|
234
|
-
|
235
|
-
|
236
|
-
@solr_resp_5_docs.
|
237
|
-
|
220
|
+
expect do
|
221
|
+
expect(@solr_resp_5_docs).to include(%w(111 222 999))
|
222
|
+
end.to raise_error.with_message a_string_including '} to include ["111", "222", "999"]'
|
223
|
+
expect do
|
224
|
+
expect(@solr_resp_5_docs).to include(%w(666 555))
|
225
|
+
end.to raise_error.with_message a_string_including '} to include ["666", "555"]'
|
238
226
|
my_srh = @solr_resp_5_docs.clone
|
239
|
-
my_srh.id_field='fld2'
|
240
|
-
|
241
|
-
my_srh.
|
242
|
-
|
227
|
+
my_srh.id_field = 'fld2'
|
228
|
+
expect do
|
229
|
+
expect(my_srh).to include(%w(val2 val9))
|
230
|
+
end.to raise_error.with_message a_string_including '} to include ["val2", "val9"]'
|
243
231
|
end
|
244
232
|
end # should include(Array_of_Strings)
|
245
|
-
|
246
|
-
context
|
233
|
+
|
234
|
+
context 'should_NOT include(Array_of_Strings)' do
|
247
235
|
it "fails if all Strings in Array match all Solr documents' id_field in the response" do
|
248
|
-
|
249
|
-
@solr_resp_5_docs.
|
250
|
-
|
236
|
+
expect do
|
237
|
+
expect(@solr_resp_5_docs).not_to include(%w(111 222 333 444 555))
|
238
|
+
end.to raise_error.with_message a_string_including 'not to include ["111", "222", "333", "444", "555"]'
|
251
239
|
my_srh = @solr_resp_5_docs.clone
|
252
|
-
my_srh.id_field='fld2'
|
253
|
-
|
254
|
-
my_srh.
|
255
|
-
|
240
|
+
my_srh.id_field = 'fld2'
|
241
|
+
expect do
|
242
|
+
expect(my_srh).not_to include(['val2'])
|
243
|
+
end.to raise_error.with_message a_string_including 'not to include ["val2"]'
|
256
244
|
end
|
257
245
|
it "fails if all Strings in Array match some Solr documents' id_field in the response" do
|
258
|
-
|
259
|
-
@solr_resp_5_docs.
|
260
|
-
|
261
|
-
|
262
|
-
@solr_resp_5_docs.
|
263
|
-
|
246
|
+
expect do
|
247
|
+
expect(@solr_resp_5_docs).not_to include(%w(111 222 333))
|
248
|
+
end.to raise_error.with_message a_string_including 'not to include ["111", "222", "333"]'
|
249
|
+
expect do
|
250
|
+
expect(@solr_resp_5_docs).not_to include(['111'])
|
251
|
+
end.to raise_error.with_message a_string_including 'not to include ["111"]'
|
264
252
|
my_srh = @solr_resp_5_docs.clone
|
265
|
-
my_srh.id_field='fld'
|
266
|
-
|
267
|
-
my_srh.
|
268
|
-
|
253
|
+
my_srh.id_field = 'fld'
|
254
|
+
expect do
|
255
|
+
expect(my_srh).not_to include(['val'])
|
256
|
+
end.to raise_error.with_message a_string_including 'not to include ["val"]'
|
269
257
|
end
|
270
258
|
it "passes if no Strings in Array match Solr documents' id_field in the response" do
|
271
|
-
@solr_resp_5_docs.
|
259
|
+
expect(@solr_resp_5_docs).not_to include(%w(888 899))
|
272
260
|
my_srh = @solr_resp_5_docs.clone
|
273
|
-
my_srh.id_field='fld2'
|
274
|
-
my_srh.
|
261
|
+
my_srh.id_field = 'fld2'
|
262
|
+
expect(my_srh).not_to include(%w(val8 val9))
|
275
263
|
end
|
276
264
|
it "passes if only some Strings in Array match Solr documents' id_field in the response" do
|
277
|
-
@solr_resp_5_docs.
|
278
|
-
@solr_resp_5_docs.
|
265
|
+
expect(@solr_resp_5_docs).not_to include(%w(111 222 999))
|
266
|
+
expect(@solr_resp_5_docs).not_to include(%w(666 555))
|
279
267
|
my_srh = @solr_resp_5_docs.clone
|
280
|
-
my_srh.id_field='fld2'
|
281
|
-
my_srh.
|
268
|
+
my_srh.id_field = 'fld2'
|
269
|
+
expect(my_srh).not_to include(%w(val2 val9))
|
282
270
|
end
|
283
271
|
end # should_not include(Array_of_Strings)
|
284
|
-
|
285
|
-
context
|
286
|
-
it
|
287
|
-
@solr_resp_5_docs.
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
@solr_resp_5_docs.
|
293
|
-
end
|
294
|
-
it
|
295
|
-
@solr_resp_5_docs.
|
296
|
-
@solr_resp_5_docs.
|
297
|
-
end
|
298
|
-
it
|
299
|
-
|
300
|
-
@solr_resp_5_docs.
|
301
|
-
|
302
|
-
end
|
303
|
-
it
|
304
|
-
|
305
|
-
@solr_resp_5_docs.
|
306
|
-
|
272
|
+
|
273
|
+
context 'should include(Array_of_Hashes)' do
|
274
|
+
it 'passes if all Hashes in Array match all Solr documents in the response' do
|
275
|
+
expect(@solr_resp_5_docs).to include([{ 'id' => '111', 'fld' => /val/, 'fld2' => 'val2' },
|
276
|
+
{ 'id' => '222' },
|
277
|
+
{ 'id' => '333', 'fld' => 'val' },
|
278
|
+
{ 'id' => '444', 'fld' => %w(val1 val2 val3) },
|
279
|
+
{ 'id' => '555' }])
|
280
|
+
expect(@solr_resp_5_docs).to include([{ 'id' => '111' }, { 'id' => '222' }, { 'id' => '333' }, { 'id' => '444' }, { 'id' => '555' }])
|
281
|
+
end
|
282
|
+
it 'passes if all Hashes in Array match some Solr documents in the response' do
|
283
|
+
expect(@solr_resp_5_docs).to include([{ 'id' => '333', 'fld' => 'val' }, { 'id' => '111', 'fld2' => 'val2' }])
|
284
|
+
expect(@solr_resp_5_docs).to include([{ 'fld' => 'val' }])
|
285
|
+
end
|
286
|
+
it 'fails if no Hashes in Array match Solr documents in the response' do
|
287
|
+
expect do
|
288
|
+
expect(@solr_resp_5_docs).to include([{ 'foo' => 'bar' }, { 'bar' => 'food', 'mmm' => 'food' }])
|
289
|
+
end.to raise_error.with_message a_string_including '} to include [{"foo" => "bar"}, {"bar" => "food", "mmm" => "food"}]'
|
290
|
+
end
|
291
|
+
it 'fails if only some Hashes in Array match Solr documents in the response' do
|
292
|
+
expect do
|
293
|
+
expect(@solr_resp_5_docs).to include([{ 'id' => '222' }, { 'id' => '333', 'fld' => 'val' }, { 'foo' => 'bar' }, { 'bar' => 'food', 'mmm' => 'food' }])
|
294
|
+
end.to raise_error.with_message a_string_including '} to include [{"id" => "222"},'
|
307
295
|
end
|
308
296
|
end # should include(Array_of_Hashes)
|
309
297
|
|
310
|
-
context
|
311
|
-
it
|
312
|
-
|
313
|
-
@solr_resp_5_docs.
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
@solr_resp_5_docs.
|
321
|
-
|
322
|
-
end
|
323
|
-
it
|
324
|
-
|
325
|
-
@solr_resp_5_docs.
|
326
|
-
|
327
|
-
|
328
|
-
@solr_resp_5_docs.
|
329
|
-
|
330
|
-
end
|
331
|
-
it
|
332
|
-
@solr_resp_5_docs.
|
333
|
-
end
|
334
|
-
it
|
335
|
-
@solr_resp_5_docs.
|
336
|
-
end
|
337
|
-
|
298
|
+
context 'should_NOT include(Array_of_Hashes)' do
|
299
|
+
it 'fails if all Hashes in Array match all Solr documents in the response' do
|
300
|
+
expect do
|
301
|
+
expect(@solr_resp_5_docs).not_to include([{ 'id' => '111', 'fld' => 'val', 'fld2' => 'val2' },
|
302
|
+
{ 'id' => '222' },
|
303
|
+
{ 'id' => '333', 'fld' => 'val' },
|
304
|
+
{ 'id' => '444', 'fld' => %w(val1 val2 val3) },
|
305
|
+
{ 'id' => '555' }])
|
306
|
+
end.to raise_error.with_message a_string_including 'not to include [{"id" => "111",'
|
307
|
+
expect do
|
308
|
+
expect(@solr_resp_5_docs).not_to include([{ 'id' => '111' }, { 'id' => '222' }, { 'id' => '333' }, { 'id' => '444' }, { 'id' => '555' }])
|
309
|
+
end.to raise_error.with_message a_string_including 'not to include [{"id" => "111"},'
|
310
|
+
end
|
311
|
+
it 'fails if all Hashes in Array match some Solr documents in the response' do
|
312
|
+
expect do
|
313
|
+
expect(@solr_resp_5_docs).not_to include([{ 'id' => '333', 'fld' => 'val' }, { 'id' => '111', 'fld2' => 'val2' }])
|
314
|
+
end.to raise_error.with_message a_string_including 'not to include [{"id" => "333",'
|
315
|
+
expect do
|
316
|
+
expect(@solr_resp_5_docs).not_to include([{ 'fld' => 'val' }])
|
317
|
+
end.to raise_error.with_message a_string_including ' not to include [{"fld" => "val"}]'
|
318
|
+
end
|
319
|
+
it 'passes if no Hashes in Array match Solr documents in the response' do
|
320
|
+
expect(@solr_resp_5_docs).not_to include([{ 'foo' => 'bar' }, { 'bar' => 'food', 'mmm' => 'food' }])
|
321
|
+
end
|
322
|
+
it 'passes if only some Hashes in Array match Solr documents in the response' do
|
323
|
+
expect(@solr_resp_5_docs).not_to include([{ 'id' => '222' }, { 'id' => '333', 'fld' => 'val' }, { 'foo' => 'bar' }, { 'bar' => 'food', 'mmm' => 'food' }])
|
324
|
+
end
|
338
325
|
end # should_not include(Array_of_Hashes)
|
339
326
|
|
340
|
-
context
|
341
|
-
it
|
342
|
-
@solr_resp_5_docs.
|
343
|
-
end
|
344
|
-
it
|
345
|
-
|
346
|
-
@solr_resp_5_docs.
|
347
|
-
|
348
|
-
|
349
|
-
@solr_resp_5_docs.
|
350
|
-
|
327
|
+
context 'mixed Array of Strings and Hashes' do
|
328
|
+
it 'passes if all elements of Array pass' do
|
329
|
+
expect(@solr_resp_5_docs).to include(['222', { 'id' => '111', 'fld' => 'val' }, '555'])
|
330
|
+
end
|
331
|
+
it 'fails if any element of Array fails' do
|
332
|
+
expect do
|
333
|
+
expect(@solr_resp_5_docs).to include(['not_there', { 'id' => '111', 'fld' => 'val' }, '555'])
|
334
|
+
end.to raise_error.with_message a_string_including '} to include ['
|
335
|
+
expect do
|
336
|
+
expect(@solr_resp_5_docs).to include(['222', { 'id' => '111', 'not' => 'there' }, '555'])
|
337
|
+
end.to raise_error.with_message a_string_including '} to include ['
|
351
338
|
end
|
352
339
|
end
|
353
|
-
|
354
|
-
it
|
355
|
-
@solr_resp_5_docs.
|
340
|
+
|
341
|
+
it 'should allow #have_documents as alternative to #include' do
|
342
|
+
expect(@solr_resp_5_docs).to have_documents(%w(111 222 333))
|
356
343
|
end
|
357
|
-
|
358
344
|
end # Array argument
|
359
345
|
|
360
|
-
|
361
|
-
context "regex value" do
|
362
|
-
|
346
|
+
context 'regex value' do
|
363
347
|
context "should include('fld' => /regex/)" do
|
364
|
-
it
|
365
|
-
@solr_resp_5_docs.
|
366
|
-
@solr_resp_5_docs.
|
367
|
-
@solr_resp_5_docs.
|
348
|
+
it 'passes if Solr document in response matches regex in named field' do
|
349
|
+
expect(@solr_resp_5_docs).to include('id' => /\d{3}/)
|
350
|
+
expect(@solr_resp_5_docs).to include('fld' => /^va/) # 2 docs match
|
351
|
+
expect(@solr_resp_5_docs).to include('fld' => /Va/i) # 2 docs match
|
368
352
|
end
|
369
|
-
it
|
370
|
-
@solr_resp_5_docs.
|
353
|
+
it 'passes if single value expectation is expressed as an Array' do
|
354
|
+
expect(@solr_resp_5_docs).to include('id' => [/111/])
|
371
355
|
end
|
372
356
|
it "fails if no Solr document in response has 'fldval' for the named field" do
|
373
|
-
|
374
|
-
@solr_resp_5_docs.
|
375
|
-
|
357
|
+
expect do
|
358
|
+
expect(@solr_resp_5_docs).to include('id' => /not there/)
|
359
|
+
end.to raise_error.with_message a_string_including '} to include {"id" => /not there/}'
|
376
360
|
end
|
377
|
-
it
|
378
|
-
|
379
|
-
@solr_resp_5_docs.
|
380
|
-
|
361
|
+
it 'fails if no Solr document in response has the named field' do
|
362
|
+
expect do
|
363
|
+
expect(@solr_resp_5_docs).to include('not_there' => /anything/)
|
364
|
+
end.to raise_error.with_message a_string_including '} to include {"not_there" => /anything/}'
|
381
365
|
end
|
382
366
|
end # should include('fld' => /regex/)
|
383
367
|
|
384
368
|
context "should_NOT include('fld' => /regex/)" do
|
385
|
-
it
|
386
|
-
|
387
|
-
@solr_resp_5_docs.
|
388
|
-
|
389
|
-
|
390
|
-
@solr_resp_5_docs.
|
391
|
-
|
369
|
+
it 'fails if Solr document in response matches regex in named field' do
|
370
|
+
expect do
|
371
|
+
expect(@solr_resp_5_docs).not_to include('id' => /\d{3}/)
|
372
|
+
end.to raise_error.with_message a_string_including 'not to include {"id" => /\d{3}/}'
|
373
|
+
expect do
|
374
|
+
expect(@solr_resp_5_docs).not_to include('fld' => /^va/)
|
375
|
+
end.to raise_error.with_message a_string_including 'not to include {"fld" => /^va/}'
|
392
376
|
end
|
393
377
|
it "passes if no Solr document in response has 'fldval' for the named field" do
|
394
|
-
|
378
|
+
expect(@solr_resp_5_docs).not_to include('id' => /not there/)
|
395
379
|
end
|
396
|
-
it
|
397
|
-
|
380
|
+
it 'passes if no Solr document in response has the named field' do
|
381
|
+
expect(@solr_resp_5_docs).not_to include('not_there' => /anything/)
|
398
382
|
end
|
399
|
-
it
|
400
|
-
@solr_resp_5_docs.
|
383
|
+
it 'passes if single field value is expressed as Array' do
|
384
|
+
expect(@solr_resp_5_docs).not_to include('id' => [/not there/])
|
401
385
|
end
|
402
|
-
|
403
386
|
end # should_NOT include('fld' => /regex/)
|
404
|
-
|
405
387
|
end # regex value
|
406
388
|
|
407
|
-
|
408
389
|
before(:all) do
|
409
|
-
@solr_resp_5_docs = RSpecSolr::SolrResponseHash.new(
|
410
|
-
{
|
411
|
-
|
412
|
-
|
413
|
-
[
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
390
|
+
@solr_resp_5_docs = RSpecSolr::SolrResponseHash.new('response' =>
|
391
|
+
{ 'numFound' => 5,
|
392
|
+
'start' => 0,
|
393
|
+
'docs' =>
|
394
|
+
[{ 'id' => '111', 'fld' => 'val', 'fld2' => 'val2' },
|
395
|
+
{ 'id' => '222' },
|
396
|
+
{ 'id' => '333', 'fld' => 'val' },
|
397
|
+
{ 'id' => '444', 'fld' => %w(val1 val2 val3) },
|
398
|
+
{ 'id' => '555' }
|
418
399
|
]
|
419
|
-
}
|
420
|
-
})
|
400
|
+
})
|
421
401
|
end
|
422
402
|
|
423
|
-
|
424
403
|
context "shouldn't break RSpec #include matcher" do
|
425
|
-
it
|
426
|
-
|
427
|
-
|
404
|
+
it 'for String' do
|
405
|
+
expect('abc').to include('a')
|
406
|
+
expect('abc').not_to include('d')
|
428
407
|
end
|
429
408
|
|
430
|
-
it
|
431
|
-
[1,2,3].
|
432
|
-
[1,2,3].
|
433
|
-
[1,2,3].
|
434
|
-
|
435
|
-
[1,2,3].
|
436
|
-
|
437
|
-
|
438
|
-
[1,2,3].
|
439
|
-
|
409
|
+
it 'for Array' do
|
410
|
+
expect([1, 2, 3]).to include(3)
|
411
|
+
expect([1, 2, 3]).to include(2, 3)
|
412
|
+
expect([1, 2, 3]).not_to include(4)
|
413
|
+
expect do
|
414
|
+
expect([1, 2, 3]).to include(1, 666)
|
415
|
+
end.to raise_error a_string_including 'to include 1 and 666'
|
416
|
+
expect do
|
417
|
+
expect([1, 2, 3]).not_to include(1, 666)
|
418
|
+
end.to raise_error a_string_including 'to include 1 and 666'
|
440
419
|
end
|
441
420
|
|
442
|
-
it
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
421
|
+
it 'for Hash' do
|
422
|
+
expect(key: 'value').to include(:key)
|
423
|
+
expect(key: 'value').not_to include(:key2)
|
424
|
+
expect do
|
425
|
+
expect(key: 'value').to include(:key, :other)
|
426
|
+
end.to raise_error a_string_including 'to include :key and :other'
|
427
|
+
expect do
|
428
|
+
expect(key: 'value').not_to include(:key, :other)
|
429
|
+
end.to raise_error a_string_including 'to include :key and :other'
|
430
|
+
expect('key' => 'value').to include('key')
|
431
|
+
expect('key' => 'value').not_to include('key2')
|
453
432
|
end
|
454
433
|
end # context shouldn't break RSpec #include matcher
|
455
|
-
|
456
434
|
end # context RSpecSolr::SolrResponseHash #include matcher
|
457
|
-
|
458
|
-
end
|
435
|
+
end
|