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,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 "have_documents with no doc matcher" do
9
- it "passes if response.should has documents" do
10
- @solr_resp_w_docs.should have_documents
11
- @solr_resp_total_but_no_docs.should have_documents
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 "passes if response.should_not has no documents" do
15
- @solr_resp_no_docs.should_not have_documents
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 "failure message for should" do
19
- lambda {
20
- @solr_resp_no_docs.should have_documents
21
- }.should fail_matching("expected documents in Solr response ")
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 "failure message for should_not" do
25
- lambda {
26
- @solr_resp_w_docs.should_not have_documents
27
- @solr_resp_total_but_no_docs.should_not have_documents
28
- }.should fail_matching("did not expect documents, but Solr response had ")
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 = { "response" =>
34
- { "numFound" => 5,
35
- "start" => 0,
36
- "docs" =>
37
- [ {"id"=>"111"},
38
- {"id"=>"222"},
39
- {"id"=>"333"},
40
- {"id"=>"444"},
41
- {"id"=>"555"}
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 = { "response" =>
47
- { "numFound" => 0,
48
- "start" => 0,
49
- "docs" => []
45
+ @solr_resp_no_docs = { 'response' =>
46
+ { 'numFound' => 0,
47
+ 'start' => 0,
48
+ 'docs' => []
50
49
  }
51
- }
52
- @solr_resp_total_but_no_docs = { "response" =>
53
- { "numFound" => 1324,
54
- "start" => 0,
55
- "docs" => []
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 "should have_facet_field()" do
8
- it "passes if response has the facet field" do
9
- @solr_resp_w_facets.should have_facet_field('ff1')
10
- @solr_resp_w_facets.should have_facet_field('ff2')
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 "passes if response has facet field but no values" do
13
- @solr_resp_w_facets.should have_facet_field('ff3')
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 "fails if response does not have the facet field" do
16
- lambda {
17
- @solr_resp_w_facets.should have_facet_field('ff4')
18
- }.should fail_matching("expected facet field ff4 with values in Solr response: ")
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 "should_NOT have_facet_field()" do
23
- it "fails if response has the facet field" do
24
- lambda {
25
- @solr_resp_w_facets.should_not have_facet_field('ff1')
26
- }.should fail_matching("expected no ff1 facet field in Solr response: ")
27
- lambda {
28
- @solr_resp_w_facets.should_not have_facet_field('ff2')
29
- }.should fail_matching("expected no ff2 facet field in Solr response: ")
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 "fails if response has facet field but no values" do
32
- lambda {
33
- @solr_resp_w_facets.should_not have_facet_field('ff3')
34
- }.should fail_matching("expected no ff3 facet field in Solr response: ")
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 "passes if response does not have the facet field" do
37
- @solr_resp_w_facets.should_not have_facet_field('ff4')
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 "should have_facet_field().with_value()" do
42
- it "passes if response has the facet field with the value" do
43
- @solr_resp_w_facets.should have_facet_field('ff1').with_value('val12')
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 "fails if response has the facet field without the value" do
46
- lambda {
47
- @solr_resp_w_facets.should have_facet_field('ff1').with_value('val22')
48
- }.should fail_matching("expected facet field ff1 with value val22 in Solr response")
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 "fails if response has facet field but no values" do
51
- lambda {
52
- @solr_resp_w_facets.should have_facet_field('ff3').with_value('val')
53
- }.should fail_matching("expected facet field ff3 with value val in Solr response")
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 "fails if response does not have the facet field" do
56
- lambda {
57
- @solr_resp_w_facets.should have_facet_field('ff4').with_value('val')
58
- }.should fail_matching("expected facet field ff4 with value val in Solr response")
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 "should_NOT have_facet_field().with_value()" do
63
- it "fails if response has the facet field with the value" do
64
- lambda {
65
- @solr_resp_w_facets.should_not have_facet_field('ff1').with_value('val12')
66
- }.should fail_matching("expected facet field ff1 not to have value val12 in Solr response")
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 "passes if response has the facet field without the value" do
69
- @solr_resp_w_facets.should_not have_facet_field('ff1').with_value('val22')
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 "passes if response has facet field but no values" do
72
- @solr_resp_w_facets.should_not have_facet_field('ff3').with_value('val')
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 "fails if response does not have the facet field" do
75
- lambda {
76
- @solr_resp_w_facets.should_not have_facet_field('ff4').with_value('val')
77
- }.should fail_matching("expected facet field ff4 in Solr response")
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
- { "response" =>
85
- { "numFound" => 5,
86
- "start" => 0,
87
- "docs" => []},
88
- "facet_counts" =>
89
- { "facet_queries" => {},
90
- "facet_fields" => {
91
- 'ff1' => ['val11', 111, 'val12', 22, 'val13', 3],
92
- 'ff2' => ['val21', 10, 'val22', 5, 'val23', 1],
93
- 'ff3' => []
94
- },
95
- 'facet_dates'=>{},
96
- 'facet_ranges'=>{}
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
@@ -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 "should include().before()" do
9
-
10
- it "passes when criteria are met" do
11
- @solr_resp_5_docs.should include("111").before("222")
12
- @solr_resp_5_docs.should include("333").before("fld"=>["val1", "val2", "val3"])
13
- @solr_resp_5_docs.should include("fld"=>"val").before("fld"=>["val1", "val2", "val3"])
14
- @solr_resp_5_docs.should include(["111", "222"]).before(["333", "555"])
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 "passes when criteria CAN BE met (more than one option)" do
18
- @solr_resp_5_docs.should include("111").before("fld"=>"val")
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
- lambda {
22
- @solr_resp_5_docs.should include("222").before("fld2"=>"val2")
23
- }.should fail_matching('expected response to include document "222" before document matching {"fld2"=>"val2"}')
24
- lambda {
25
- @solr_resp_5_docs.should include("111", "444").before([{"id"=>"333"}, {"id"=>"555"}])
26
- }.should fail_matching('expected response to include documents "111" and "444" before documents matching [{"id"=>"333"}, {"id"=>"555"}]')
27
- lambda {
28
- @solr_resp_5_docs.should include([{"id"=>"222"}, {"id"=>"444"}]).before([{"id"=>"333"}, {"id"=>"555"}])
29
- }.should fail_matching('expected response to include documents [{"id"=>"222"}, {"id"=>"444"}] before documents matching [{"id"=>"333"}, {"id"=>"555"}]')
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
- lambda {
33
- @solr_resp_5_docs.should include("not_there").before("555")
34
- }.should fail_matching('expected response to include document "not_there" before document matching "555"')
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
- lambda {
38
- @solr_resp_5_docs.should include("222").before("not_there")
39
- }.should fail_matching('expected response to include document "222" before document matching "not_there"')
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
- lambda {
43
- @solr_resp_5_docs.should include("not_there").before("still_not_there")
44
- }.should fail_matching('expected response to include document "not_there" before document matching "still_not_there"')
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
- context "should_NOT include().before()" do
51
-
52
- it "fails when criteria are met" do
53
- lambda {
54
- @solr_resp_5_docs.should_not include("111").before("222")
55
- }.should fail_matching('not to include document "111" before document matching "222"')
56
- lambda {
57
- @solr_resp_5_docs.should_not include("333").before("fld"=>["val1", "val2", "val3"])
58
- }.should fail_matching('not to include document "333" before document matching {"fld"=>["val1", "val2", "val3"]}')
59
- lambda {
60
- @solr_resp_5_docs.should_not include("fld"=>"val").before("fld"=>["val1", "val2", "val3"])
61
- }.should fail_matching('not to include document {"fld"=>"val"} before document matching {"fld"=>["val1", "val2", "val3"]}')
62
- lambda {
63
- @solr_resp_5_docs.should_not include(["111", "222"]).before(["333", "555"])
64
- }.should fail_matching('not to include documents ["111", "222"] before documents matching ["333", "555"]')
65
- lambda {
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 "fails when criteria CAN BE met (more than one option)" do
70
- lambda {
71
- @solr_resp_5_docs.should_not include("111").before("fld"=>"val")
72
- }.should fail_matching('not to include document "111" before document matching {"fld"=>"val"}')
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
- @solr_resp_5_docs.should_not include("222").before("fld2"=>"val2")
76
- # NOTE: it is picky about the next line include() being ["111", "444"], not just "111", "444"
77
- @solr_resp_5_docs.should_not include(["111", "444"]).before([{"id"=>"333"}, {"id"=>"555"}])
78
- @solr_resp_5_docs.should_not include([{"id"=>"222"}, {"id"=>"444"}]).before([{"id"=>"333"}, {"id"=>"555"}])
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.should_not include("not_there").before("555")
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.should_not include("222").before("not_there")
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.should_not include("not_there").before("still_not_there")
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({ "response" =>
94
- { "numFound" => 5,
95
- "start" => 0,
96
- "docs" =>
97
- [ {"id"=>"111", "fld"=>"val", "fld2"=>"val2"},
98
- {"id"=>"222"},
99
- {"id"=>"333", "fld"=>"val"},
100
- {"id"=>"444", "fld"=>["val1", "val2", "val3"]},
101
- {"id"=>"555"}
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.should include("id" => "111")
14
- @solr_resp_5_docs.should include("fld" => "val") # 2 docs match
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 "passes if single value expectation is expressed as an Array" do
17
- @solr_resp_5_docs.should include("id" => ["111"])
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
- lambda {
21
- @solr_resp_5_docs.should include("id" => "not_there")
22
- }.should fail_matching('} to include {"id"=>"not_there"}')
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 "fails if no Solr document in response has the named field" do
25
- lambda {
26
- @solr_resp_5_docs.should include("not_there" => "anything")
27
- }.should fail_matching('} to include {"not_there"=>"anything"}')
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
- lambda {
35
- @solr_resp_5_docs.should_not include("id" => "111")
36
- }.should fail_matching('not to include {"id"=>"111"}')
37
- lambda {
38
- @solr_resp_5_docs.should_not include("fld" => "val")
39
- }.should fail_matching('not to include {"fld"=>"val"}')
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
- @solr_resp_5_docs.should_not include({"id" => "not_there"})
38
+ expect(@solr_resp_5_docs).not_to include('id' => 'not_there')
43
39
  end
44
- it "passes if no Solr document in response has the named field" do
45
- @solr_resp_5_docs.should_not include({"not_there" => "anything"})
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 "passes if single field value is expressed as Array" do
48
- @solr_resp_5_docs.should_not include({"id" => ["not_there"]})
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
- it "passes if all pairs are included in a Solr document in the response" do
55
- @solr_resp_5_docs.should include("id" => "111", "fld" => "val")
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 "fails if only part of expectation is met" do
59
- lambda {
60
- @solr_resp_5_docs.should include("id" => "111", "fld" => "not_there")
61
- }.should fail_matching('} to include {"id"=>"111", "fld"=>"not_there"}')
62
- lambda {
63
- @solr_resp_5_docs.should include("id" => "111", "not_there" => "whatever")
64
- }.should fail_matching('} to include {"id"=>"111", "not_there"=>"whatever"}')
65
- lambda {
66
- @solr_resp_5_docs.should include("id" => "222", "fld" => "val")
67
- }.should fail_matching('} to include {"id"=>"222", "fld"=>"val"}')
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 "fails if no part of expectation is met" do
70
- lambda {
71
- @solr_resp_5_docs.should include("id" => "not_there", "not_there" => "anything")
72
- }.should fail_matching('} to include {"id"=>"not_there", "not_there"=>"anything"}')
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
- it "fails if a Solr document in the response contains all the key/value pairs" do
79
- lambda {
80
- @solr_resp_5_docs.should_not include("id" => "333", "fld" => "val")
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 "passes if a Solr document in the response contains all the key/value pairs among others" do
84
- lambda {
85
- @solr_resp_5_docs.should_not include("id" => "111", "fld" => "val")
86
- }.should fail_matching('not to include {"id"=>"111", "fld"=>"val"}')
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 "passes if part of the expectation is not met" do
89
- @solr_resp_5_docs.should_not include("id" => "111", "fld" => "not_there")
90
- @solr_resp_5_docs.should_not include("id" => "111", "not_there" => "whatever")
91
- @solr_resp_5_docs.should_not include("id" => "222", "fld" => "val")
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 "passes if no part of the expectatio is met" do
94
- @solr_resp_5_docs.should_not include("id" => "not_there", "not_there" => "anything")
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 "multi-valued fields and expectations" do
99
-
100
- context "should include(doc_exp)" do
101
- it "passes if all the expected values match all the values in a Solr document in the response" do
102
- @solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"])
103
- @solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"], "id" => "444")
104
- end
105
- it "passes if all the expected values match some of the values in a Solr document in the response" do
106
- @solr_resp_5_docs.should include("fld" => ["val1", "val2"])
107
- @solr_resp_5_docs.should include("fld" => "val1")
108
- @solr_resp_5_docs.should include("fld" => ["val1", "val2"], "id" => "444")
109
- end
110
- it "fails if none of the expected values match the values in a Solr document in the response" do
111
- lambda {
112
- @solr_resp_5_docs.should include("fld" => ["not_there", "also_not_there"])
113
- }.should fail_matching('} to include {"fld"=>["not_there", "also_not_there"]}')
114
- end
115
- it "fails if only some of the expected values match the values in a Solr document in the response" do
116
- lambda {
117
- @solr_resp_5_docs.should include("fld" => ["val1", "val2", "not_there"])
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 "should_NOT include(doc_exp)" do
123
- it "fails if all the expected values match all the values in a Solr document in the response" do
124
- lambda {
125
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "val3"])
126
- }.should fail_matching('not to include {"fld"=>["val1", "val2", "val3"]}')
127
- lambda {
128
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "val3"], "id" => "444")
129
- }.should fail_matching('not to include {"fld"=>["val1", "val2", "val3"], "id"=>"444"}')
130
- end
131
- it "fails if all the expected values match some of the values in a Solr document in the response" do
132
- lambda {
133
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2"])
134
- }.should fail_matching('not to include {"fld"=>["val1", "val2"]}')
135
- lambda {
136
- @solr_resp_5_docs.should_not include("fld" => "val1")
137
- }.should fail_matching('not to include {"fld"=>"val1"}')
138
- lambda {
139
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2"], "id" => "444")
140
- }.should fail_matching('not to include {"fld"=>["val1", "val2"], "id"=>"444"}')
141
- end
142
- it "passes if none of the expected values match the values in a Solr document in the response" do
143
- @solr_resp_5_docs.should_not include("fld" => ["not_there", "also_not_there"])
144
- @solr_resp_5_docs.should_not include("fld" => ["not_there", "also_not_there"], "id" => "444")
145
- end
146
- it "passes if only some of the expected values match the values in a Solr document in the response" do
147
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "not_there"])
148
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "not_there"], "id" => "444")
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
- context "single String argument" do
156
-
157
- context "should include(single_string_arg)" do
158
- it "passes if string matches default id_field of Solr document in the response" do
159
- @solr_resp_5_docs.should include('111')
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.should include('val2')
153
+ my_srh.id_field = 'fld2'
154
+ expect(my_srh).to include('val2')
165
155
  end
166
- it "fails if string does not match default id_field of Solr document in the response" do
167
- lambda {
168
- @solr_resp_5_docs.should include('666')
169
- }.should fail_matching('} to include "666"')
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
- lambda {
175
- my_srh.should include('val')
176
- }.should fail_matching('} to include "val"')
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 "should_NOT include(single_string_arg)" do
181
- it "fails if string matches default id_field of Solr document in the response" do
182
- lambda {
183
- @solr_resp_5_docs.should_not include('111')
184
- }.should fail_matching('not to include "111"')
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 "fails if string matches non-default id_field in the SolrResponseHash object" do
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
- lambda {
190
- my_srh.should_not include('val2')
191
- }.should fail_matching('not to include "val2"')
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 "passes if string does not match default id_field of Solr document in the response" do
194
- @solr_resp_5_docs.should_not include('666')
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.should_not include('val')
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 "Array argument" do
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.should include(["111", "222", "333", "444", "555"])
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.should include(["val2"])
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.should include(["111", "222", "333"])
216
- @solr_resp_5_docs.should include(["111"])
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.should include(["val"])
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
- lambda {
223
- @solr_resp_5_docs.should include(["888", "899"])
224
- }.should fail_matching ('} to include ["888", "899"]')
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
- lambda {
228
- my_srh.should include(["val8", "val9"])
229
- }.should fail_matching ('} to include ["val8", "val9"]')
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
- lambda {
233
- @solr_resp_5_docs.should include(["111", "222", "999"])
234
- }.should fail_matching('} to include ["111", "222", "999"]')
235
- lambda {
236
- @solr_resp_5_docs.should include(["666", "555"])
237
- }.should fail_matching('} to include ["666", "555"]')
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
- lambda {
241
- my_srh.should include(["val2", "val9"])
242
- }.should fail_matching('} to include ["val2", "val9"]')
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 "should_NOT include(Array_of_Strings)" do
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
- lambda {
249
- @solr_resp_5_docs.should_not include(["111", "222", "333", "444", "555"])
250
- }.should fail_matching('not to include ["111", "222", "333", "444", "555"]')
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
- lambda {
254
- my_srh.should_not include(["val2"])
255
- }.should fail_matching('not to include ["val2"]')
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
- lambda {
259
- @solr_resp_5_docs.should_not include(["111", "222", "333"])
260
- }.should fail_matching('not to include ["111", "222", "333"]')
261
- lambda {
262
- @solr_resp_5_docs.should_not include(["111"])
263
- }.should fail
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
- lambda {
267
- my_srh.should_not include(["val"])
268
- }.should fail_matching('not to include ["val"]')
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.should_not include(["888", "899"])
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.should_not include(["val8", "val9"])
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.should_not include(["111", "222", "999"])
278
- @solr_resp_5_docs.should_not include(["666", "555"])
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.should_not include(["val2", "val9"])
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 "should include(Array_of_Hashes)" do
286
- it "passes if all Hashes in Array match all Solr documents in the response" do
287
- @solr_resp_5_docs.should include([{"id"=>"111", "fld"=>/val/, "fld2"=>"val2"},
288
- {"id"=>"222"},
289
- {"id"=>"333", "fld"=>"val"},
290
- {"id"=>"444", "fld"=>["val1", "val2", "val3"]},
291
- {"id"=>"555"}])
292
- @solr_resp_5_docs.should include([{"id"=>"111"}, {"id"=>"222"}, {"id"=>"333"}, {"id"=>"444"}, {"id"=>"555"}])
293
- end
294
- it "passes if all Hashes in Array match some Solr documents in the response" do
295
- @solr_resp_5_docs.should include([{"id"=>"333", "fld"=>"val"}, {"id"=>"111", "fld2"=>"val2"}])
296
- @solr_resp_5_docs.should include([{"fld"=>"val"}])
297
- end
298
- it "fails if no Hashes in Array match Solr documents in the response" do
299
- lambda {
300
- @solr_resp_5_docs.should include([{"foo"=>"bar"}, {"bar"=>"food", "mmm"=>"food"}])
301
- }.should fail_matching('} to include [{"foo"=>"bar"}, {"bar"=>"food", "mmm"=>"food"}]')
302
- end
303
- it "fails if only some Hashes in Array match Solr documents in the response" do
304
- lambda {
305
- @solr_resp_5_docs.should include([{"id"=>"222"}, {"id"=>"333", "fld"=>"val"}, {"foo"=>"bar"}, {"bar"=>"food", "mmm"=>"food"}])
306
- }.should fail_matching('} to include [{"id"=>"222"},')
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 "should_NOT include(Array_of_Hashes)" do
311
- it "fails if all Hashes in Array match all Solr documents in the response" do
312
- lambda {
313
- @solr_resp_5_docs.should_not include([{"id"=>"111", "fld"=>"val", "fld2"=>"val2"},
314
- {"id"=>"222"},
315
- {"id"=>"333", "fld"=>"val"},
316
- {"id"=>"444", "fld"=>["val1", "val2", "val3"]},
317
- {"id"=>"555"}])
318
- }.should fail
319
- lambda {
320
- @solr_resp_5_docs.should_not include([{"id"=>"111"}, {"id"=>"222"}, {"id"=>"333"}, {"id"=>"444"}, {"id"=>"555"}])
321
- }.should fail_matching('not to include [{"id"=>"111"},')
322
- end
323
- it "fails if all Hashes in Array match some Solr documents in the response" do
324
- lambda {
325
- @solr_resp_5_docs.should_not include([{"id"=>"333", "fld"=>"val"}, {"id"=>"111", "fld2"=>"val2"}])
326
- }.should fail_matching('not to include [{"id"=>"333",')
327
- lambda {
328
- @solr_resp_5_docs.should_not include([{"fld"=>"val"}])
329
- }.should fail
330
- end
331
- it "passes if no Hashes in Array match Solr documents in the response" do
332
- @solr_resp_5_docs.should_not include([{"foo"=>"bar"}, {"bar"=>"food", "mmm"=>"food"}])
333
- end
334
- it "passes if only some Hashes in Array match Solr documents in the response" do
335
- @solr_resp_5_docs.should_not include([{"id"=>"222"}, {"id"=>"333", "fld"=>"val"}, {"foo"=>"bar"}, {"bar"=>"food", "mmm"=>"food"}])
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 "mixed Array of Strings and Hashes" do
341
- it "passes if all elements of Array pass" do
342
- @solr_resp_5_docs.should include([ "222", {"id"=>"111", "fld"=>"val"}, "555" ])
343
- end
344
- it "fails if any element of Array fails" do
345
- lambda {
346
- @solr_resp_5_docs.should include([ "not_there", {"id"=>"111", "fld"=>"val"}, "555" ])
347
- }.should fail_matching('} to include [')
348
- lambda {
349
- @solr_resp_5_docs.should include([ "222", {"id"=>"111", "not"=>"there"}, "555" ])
350
- }.should fail_matching('} to include [')
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 "should allow #have_documents as alternative to #include" do
355
- @solr_resp_5_docs.should have_documents(["111", "222", "333"])
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 "passes if Solr document in response matches regex in named field" do
365
- @solr_resp_5_docs.should include("id" => /\d{3}/)
366
- @solr_resp_5_docs.should include("fld" => /^va/) # 2 docs match
367
- @solr_resp_5_docs.should include("fld" => /Va/i) # 2 docs match
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 "passes if single value expectation is expressed as an Array" do
370
- @solr_resp_5_docs.should include("id" => [/111/])
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
- lambda {
374
- @solr_resp_5_docs.should include("id" => /not there/)
375
- }.should fail_matching('} to include {"id"=>/not there/}')
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 "fails if no Solr document in response has the named field" do
378
- lambda {
379
- @solr_resp_5_docs.should include("not_there" => /anything/)
380
- }.should fail_matching('} to include {"not_there"=>/anything/}')
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 "fails if Solr document in response matches regex in named field" do
386
- lambda {
387
- @solr_resp_5_docs.should_not include("id" => /\d{3}/)
388
- }.should fail_matching('not to include {"id"=>/\d{3}/}')
389
- lambda {
390
- @solr_resp_5_docs.should_not include("fld" => /^va/)
391
- }.should fail_matching('not to include {"fld"=>/^va/}')
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
- @solr_resp_5_docs.should_not include({"id" => /not there/})
378
+ expect(@solr_resp_5_docs).not_to include('id' => /not there/)
395
379
  end
396
- it "passes if no Solr document in response has the named field" do
397
- @solr_resp_5_docs.should_not include({"not_there" => /anything/})
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 "passes if single field value is expressed as Array" do
400
- @solr_resp_5_docs.should_not include({"id" => [/not there/]})
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({ "response" =>
410
- { "numFound" => 5,
411
- "start" => 0,
412
- "docs" =>
413
- [ {"id"=>"111", "fld"=>"val", "fld2"=>"val2"},
414
- {"id"=>"222"},
415
- {"id"=>"333", "fld"=>"val"},
416
- {"id"=>"444", "fld"=>["val1", "val2", "val3"]},
417
- {"id"=>"555"}
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 "for String" do
426
- "abc".should include("a")
427
- "abc".should_not include("d")
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 "for Array" do
431
- [1,2,3].should include(3)
432
- [1,2,3].should include(2,3)
433
- [1,2,3].should_not include(4)
434
- lambda {
435
- [1,2,3].should include(1,666)
436
- }.should fail
437
- lambda {
438
- [1,2,3].should_not include(1,666)
439
- }.should fail
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 "for Hash" do
443
- {:key => 'value'}.should include(:key)
444
- {:key => 'value'}.should_not include(:key2)
445
- lambda {
446
- {:key => 'value'}.should include(:key, :other)
447
- }.should fail
448
- lambda {
449
- {:key => 'value'}.should_not include(:key, :other)
450
- }.should fail
451
- {'key' => 'value'}.should include('key')
452
- {'key' => 'value'}.should_not include('key2')
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