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.
@@ -2,102 +2,99 @@ require 'spec_helper'
2
2
  require 'rspec-solr'
3
3
 
4
4
  describe RSpecSolr do
5
-
6
5
  # fixtures below
7
-
8
- context "#include().in_each_of_first(n)" do
9
- context "should" do
10
- it "passes when all docs in range meet criteria" do
11
- @solr_resp.should include("fld" => "val").in_each_of_first(2)
12
- @solr_resp.should include("fld" => "val").in_each_of_first(2).documents
13
- @solr_resp.should include("fld" => "val").in_each_of_first(2).results
6
+
7
+ context '#include().in_each_of_first(n)' do
8
+ context 'should' do
9
+ it 'passes when all docs in range meet criteria' do
10
+ expect(@solr_resp).to include('fld' => 'val').in_each_of_first(2)
11
+ expect(@solr_resp).to include('fld' => 'val').in_each_of_first(2).documents
12
+ expect(@solr_resp).to include('fld' => 'val').in_each_of_first(2).results
14
13
  end
15
- it "passes when all docs in range meet regex criteria" do
16
- @solr_resp.should include("fld" => /val/).in_each_of_first(2)
17
- @solr_resp.should include("fld" => /al/).in_each_of_first(2)
18
- @solr_resp.should include("fld" => /Val/i).in_each_of_first(2)
14
+ it 'passes when all docs in range meet regex criteria' do
15
+ expect(@solr_resp).to include('fld' => /val/).in_each_of_first(2)
16
+ expect(@solr_resp).to include('fld' => /al/).in_each_of_first(2)
17
+ expect(@solr_resp).to include('fld' => /Val/i).in_each_of_first(2)
19
18
  end
20
19
  it "fails when doc in range doesn't meet criteria" do
21
- lambda {
22
- @solr_resp.should include("fld2" => "val2").in_each_of_first(2)
23
- }.should fail_matching('expected each of the first 2 documents to include {"fld2"=>"val2"}')
24
- lambda {
25
- @solr_resp.should include("fld" => "val").in_each_of_first(3)
26
- }.should fail_matching('expected each of the first 3 documents to include {"fld"=>"val"}')
20
+ expect do
21
+ expect(@solr_resp).to include('fld2' => 'val2').in_each_of_first(2)
22
+ end.to raise_error.with_message a_string_including 'expected each of the first 2 documents to include {"fld2"=>"val2"}'
23
+ expect do
24
+ expect(@solr_resp).to include('fld' => 'val').in_each_of_first(3)
25
+ end.to raise_error.with_message a_string_including 'expected each of the first 3 documents to include {"fld"=>"val"}'
27
26
  end
28
27
  it "fails when doc in range doesn't meet regex criteria" do
29
- lambda {
30
- @solr_resp.should include("fld2" => /l2/).in_each_of_first(2)
31
- }.should fail_matching('expected each of the first 2 documents to include {"fld2"=>/l2/}')
32
- lambda {
33
- @solr_resp.should include("fld" => /al/).in_each_of_first(3)
34
- }.should fail_matching('expected each of the first 3 documents to include {"fld"=>/al/}')
28
+ expect do
29
+ expect(@solr_resp).to include('fld2' => /l2/).in_each_of_first(2)
30
+ end.to raise_error.with_message a_string_including 'expected each of the first 2 documents to include {"fld2"=>/l2/}'
31
+ expect do
32
+ expect(@solr_resp).to include('fld' => /al/).in_each_of_first(3)
33
+ end.to raise_error.with_message a_string_including 'expected each of the first 3 documents to include {"fld"=>/al/}'
35
34
  end
36
35
  end
37
- context "should_NOT" do
38
- it "fails when all docs in range meet criteria" do
39
- lambda {
40
- @solr_resp.should_not include("fld" => "val").in_each_of_first(2)
41
- }.should fail_matching('expected some of the first 2 documents not to include {"fld"=>"val"}')
42
- lambda {
43
- @solr_resp.should_not include("fld" => "val").in_each_of_first(2).documents
44
- }.should fail_matching('expected some of the first 2 documents not to include {"fld"=>"val"}')
45
- lambda {
46
- @solr_resp.should_not include("fld" => "val").in_each_of_first(2).results
47
- }.should fail_matching('expected some of the first 2 documents not to include {"fld"=>"val"}')
36
+ context 'should_NOT' do
37
+ it 'fails when all docs in range meet criteria' do
38
+ expect do
39
+ expect(@solr_resp).not_to include('fld' => 'val').in_each_of_first(2)
40
+ end.to raise_error.with_message a_string_including 'expected some of the first 2 documents not to include {"fld"=>"val"}'
41
+ expect do
42
+ expect(@solr_resp).not_to include('fld' => 'val').in_each_of_first(2).documents
43
+ end.to raise_error.with_message a_string_including 'expected some of the first 2 documents not to include {"fld"=>"val"}'
44
+ expect do
45
+ expect(@solr_resp).not_to include('fld' => 'val').in_each_of_first(2).results
46
+ end.to raise_error.with_message a_string_including 'expected some of the first 2 documents not to include {"fld"=>"val"}'
48
47
  end
49
- it "fails when all docs in range meet regex criteria" do
50
- lambda {
51
- @solr_resp.should_not include("fld" => /val/).in_each_of_first(2)
52
- }.should fail_matching('expected some of the first 2 documents not to include {"fld"=>/val/}')
53
- lambda {
54
- @solr_resp.should_not include("fld" => /al/).in_each_of_first(2)
55
- }.should fail_matching('expected some of the first 2 documents not to include {"fld"=>/al/}')
56
- lambda {
57
- @solr_resp.should_not include("fld" => /Val/i).in_each_of_first(2)
58
- }.should fail_matching('expected some of the first 2 documents not to include {"fld"=>/Val/i}')
48
+ it 'fails when all docs in range meet regex criteria' do
49
+ expect do
50
+ expect(@solr_resp).not_to include('fld' => /val/).in_each_of_first(2)
51
+ end.to raise_error.with_message a_string_including 'expected some of the first 2 documents not to include {"fld"=>/val/}'
52
+ expect do
53
+ expect(@solr_resp).not_to include('fld' => /al/).in_each_of_first(2)
54
+ end.to raise_error.with_message a_string_including 'expected some of the first 2 documents not to include {"fld"=>/al/}'
55
+ expect do
56
+ expect(@solr_resp).not_to include('fld' => /Val/i).in_each_of_first(2)
57
+ end.to raise_error.with_message a_string_including 'expected some of the first 2 documents not to include {"fld"=>/Val/i}'
59
58
  end
60
59
  it "passes when doc in range doesn't meet criteria" do
61
- @solr_resp.should_not include("fld" => "val").in_each_of_first(3)
62
- @solr_resp.should_not include("fld2" => "val2").in_each_of_first(2)
60
+ expect(@solr_resp).not_to include('fld' => 'val').in_each_of_first(3)
61
+ expect(@solr_resp).not_to include('fld2' => 'val2').in_each_of_first(2)
63
62
  end
64
63
  it "passes when doc in range doesn't meet regex criteria" do
65
- @solr_resp.should_not include("fld2" => /l2/).in_each_of_first(2)
66
- @solr_resp.should_not include("fld" => /al/).in_each_of_first(3)
64
+ expect(@solr_resp).not_to include('fld2' => /l2/).in_each_of_first(2)
65
+ expect(@solr_resp).not_to include('fld' => /al/).in_each_of_first(3)
67
66
  end
68
67
  end
69
- it "should expect a Hash for the include" do
70
- expect {
71
- @solr_resp.should include("111").in_each_of_first(1)
72
- }.to raise_error(ArgumentError, "in_each_of_first(n) requires a Hash argument to include() method")
73
- expect {
74
- @solr_resp.should include(["111", "222"]).in_each_of_first(1)
75
- }.to raise_error(ArgumentError, "in_each_of_first(n) requires a Hash argument to include() method")
76
- expect {
77
- @solr_resp.should_not include("111").in_each_of_first(1)
78
- }.to raise_error(ArgumentError, "in_each_of_first(n) requires a Hash argument to include() method")
79
- expect {
80
- @solr_resp.should include("fld" => "val").in_each_of_first(1)
81
- }.to_not raise_error(ArgumentError)
82
- expect {
83
- @solr_resp.should include({"fld" => "val", "fld2" => "val2"}).in_each_of_first(1)
84
- }.to_not raise_error(ArgumentError)
68
+ it 'should expect a Hash for the include' do
69
+ expect do
70
+ expect(@solr_resp).to include('111').in_each_of_first(1)
71
+ end.to raise_error(ArgumentError, 'in_each_of_first(n) requires a Hash argument to include() method')
72
+ expect do
73
+ expect(@solr_resp).to include(%w(111 222)).in_each_of_first(1)
74
+ end.to raise_error(ArgumentError, 'in_each_of_first(n) requires a Hash argument to include() method')
75
+ expect do
76
+ expect(@solr_resp).not_to include('111').in_each_of_first(1)
77
+ end.to raise_error(ArgumentError, 'in_each_of_first(n) requires a Hash argument to include() method')
78
+ expect do
79
+ expect(@solr_resp).to include('fld' => 'val').in_each_of_first(1)
80
+ end.to_not raise_error
81
+ expect do
82
+ expect(@solr_resp).to include('fld' => 'val', 'fld2' => 'val2').in_each_of_first(1)
83
+ end.to_not raise_error
85
84
  end
86
85
  end
87
-
86
+
88
87
  before(:all) do
89
- @solr_resp = RSpecSolr::SolrResponseHash.new({ "response" =>
90
- { "numFound" => 5,
91
- "start" => 0,
92
- "docs" =>
93
- [ {"id"=>"111", "fld"=>"val", "fld2"=>"val2"},
94
- {"id"=>"222", "fld"=>"val"},
95
- {"id"=>"333"},
96
- {"id"=>"444", "fld"=>["val1", "val2", "val3"]},
97
- {"id"=>"555"}
88
+ @solr_resp = RSpecSolr::SolrResponseHash.new('response' =>
89
+ { 'numFound' => 5,
90
+ 'start' => 0,
91
+ 'docs' =>
92
+ [{ 'id' => '111', 'fld' => 'val', 'fld2' => 'val2' },
93
+ { 'id' => '222', 'fld' => 'val' },
94
+ { 'id' => '333' },
95
+ { 'id' => '444', 'fld' => %w(val1 val2 val3) },
96
+ { 'id' => '555' }
98
97
  ]
99
- }
100
- })
98
+ })
101
99
  end
102
-
103
- end
100
+ end
@@ -2,232 +2,228 @@ require 'spec_helper'
2
2
  require 'rspec-solr'
3
3
 
4
4
  describe RSpecSolr do
5
-
6
5
  # fixtures below
7
-
8
- context "#include().in_first(n)" do
9
- context "should include().in_first(n)" do
10
- it "passes when include arg is String and doc meets criteria" do
11
- @solr_resp_5_docs.should include("222").in_first(3)
12
- @solr_resp_5_docs.should include("111").in_first(1)
13
- @solr_resp_5_docs.should include("222").in_first(2)
14
- end
15
- it "fails when include arg is String but doc comes too late" do
16
- lambda {
17
- @solr_resp_5_docs.should include("222").in_first(1)
18
- }.should fail_matching('expected response to include document "222" in first 1')
19
- end
20
- it "passes when include arg is Hash and doc meets criteria" do
21
- @solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"]).in_first(4)
22
- end
23
- it "fails when include arg is Hash but doc comes too late" do
24
- lambda {
25
- @solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"]).in_first(2)
26
- }.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 2')
27
- end
28
- it "passes when include arg is Array and all docs meet criteria" do
29
- @solr_resp_5_docs.should include(["111", "222"]).in_first(2)
30
- @solr_resp_5_docs.should include(["333", {"fld2"=>"val2"}]).in_first(4)
31
- end
32
- it "fails when include arg is Array but at least one doc comes too late" do
33
- lambda {
34
- @solr_resp_5_docs.should include(["111", "444"]).in_first(2)
35
- }.should fail_matching('expected response to include documents ["111", "444"] in first 2')
36
- lambda {
37
- @solr_resp_5_docs.should include(["333", {"fld2"=>"val2"}]).in_first(2)
38
- }.should fail_matching('expected response to include documents ["333", {"fld2"=>"val2"}] in first 2')
39
- end
40
- it "fails when there is no matching result" do
41
- lambda {
42
- @solr_resp_5_docs.should include("666").in_first(6)
43
- }.should fail_matching('expected response to include document "666" in first 6')
44
- lambda {
45
- @solr_resp_5_docs.should include("fld"=>"not there").in_first(3)
46
- }.should fail_matching('expected response to include document {"fld"=>"not there"} in first 3')
47
- lambda {
48
- @solr_resp_5_docs.should include("666", "777").in_first(6)
49
- }.should fail_matching('expected response to include documents "666" and "777" in first 6')
6
+
7
+ context '#include().in_first(n)' do
8
+ context 'should include().in_first(n)' do
9
+ it 'passes when include arg is String and doc meets criteria' do
10
+ expect(@solr_resp_5_docs).to include('222').in_first(3)
11
+ expect(@solr_resp_5_docs).to include('111').in_first(1)
12
+ expect(@solr_resp_5_docs).to include('222').in_first(2)
13
+ end
14
+ it 'fails when include arg is String but doc comes too late' do
15
+ expect do
16
+ expect(@solr_resp_5_docs).to include('222').in_first(1)
17
+ end.to raise_error.with_message a_string_including 'expected response to include document "222" in first 1'
18
+ end
19
+ it 'passes when include arg is Hash and doc meets criteria' do
20
+ expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3)).in_first(4)
21
+ end
22
+ it 'fails when include arg is Hash but doc comes too late' do
23
+ expect do
24
+ expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3)).in_first(2)
25
+ end.to raise_error.with_message a_string_including 'expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 2'
26
+ end
27
+ it 'passes when include arg is Array and all docs meet criteria' do
28
+ expect(@solr_resp_5_docs).to include(%w(111 222)).in_first(2)
29
+ expect(@solr_resp_5_docs).to include(['333', { 'fld2' => 'val2' }]).in_first(4)
30
+ end
31
+ it 'fails when include arg is Array but at least one doc comes too late' do
32
+ expect do
33
+ expect(@solr_resp_5_docs).to include(%w(111 444)).in_first(2)
34
+ end.to raise_error.with_message a_string_including 'expected response to include documents ["111", "444"] in first 2'
35
+ expect do
36
+ expect(@solr_resp_5_docs).to include(['333', { 'fld2' => 'val2' }]).in_first(2)
37
+ end.to raise_error.with_message a_string_including 'expected response to include documents ["333", {"fld2"=>"val2"}] in first 2'
38
+ end
39
+ it 'fails when there is no matching result' do
40
+ expect do
41
+ expect(@solr_resp_5_docs).to include('666').in_first(6)
42
+ end.to raise_error.with_message a_string_including 'expected response to include document "666" in first 6'
43
+ expect do
44
+ expect(@solr_resp_5_docs).to include('fld' => 'not there').in_first(3)
45
+ end.to raise_error.with_message a_string_including 'expected response to include document {"fld"=>"not there"} in first 3'
46
+ expect do
47
+ expect(@solr_resp_5_docs).to include('666', '777').in_first(6)
48
+ end.to raise_error.with_message a_string_including 'expected response to include documents "666" and "777" in first 6'
50
49
  end
51
50
  end # should include().in_first(n)
52
51
 
53
- context "should_NOT include().in_first(n)" do
54
- it "fails when include arg is String and doc meets criteria" do
55
- lambda {
56
- @solr_resp_5_docs.should_not include("222").in_first(2)
57
- }.should fail_matching('not to include document "222" in first 2')
58
- end
59
- it "passes when include arg is String but doc comes too late" do
60
- @solr_resp_5_docs.should_not include("222").in_first(1)
61
- end
62
- it "fails when include arg is Hash and doc meets criteria" do
63
- lambda {
64
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "val3"]).in_first(4)
65
- }.should fail_matching('not to include document {"fld"=>["val1", "val2", "val3"]} in first 4')
66
- end
67
- it "passes when include arg is Hash but doc comes too late" do
68
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "val3"]).in_first(2)
69
- end
70
- it "fails when include arg is Array and all docs meet criteria" do
71
- lambda {
72
- @solr_resp_5_docs.should_not include("111", "222").in_first(2)
73
- }.should fail_matching('not to include documents "111" and "222" in first 2')
74
- lambda {
75
- @solr_resp_5_docs.should_not include(["333", {"fld2"=>"val2"}]).in_first(4)
76
- }.should fail_matching('not to include documents ["333", {"fld2"=>"val2"}] in first 4')
77
- end
78
- it "passes when include arg is Array but at least one doc comes too late" do
79
- @solr_resp_5_docs.should_not include(["111", "444"]).in_first(2)
80
- @solr_resp_5_docs.should_not include(["333", {"fld2"=>"val2"}]).in_first(2)
81
- end
82
- it "passes when there is no matching result" do
83
- @solr_resp_5_docs.should_not include("666").in_first(6)
84
- @solr_resp_5_docs.should_not include("fld"=>"not there").in_first(3)
85
- @solr_resp_5_docs.should_not include("666", "777").in_first(6)
86
- end
87
- end # should_NOT include().in_first(n)
52
+ context 'should_NOT include().in_first(n)' do
53
+ it 'fails when include arg is String and doc meets criteria' do
54
+ expect do
55
+ expect(@solr_resp_5_docs).not_to include('222').in_first(2)
56
+ end.to raise_error.with_message a_string_including 'not to include document "222" in first 2'
57
+ end
58
+ it 'passes when include arg is String but doc comes too late' do
59
+ expect(@solr_resp_5_docs).not_to include('222').in_first(1)
60
+ end
61
+ it 'fails when include arg is Hash and doc meets criteria' do
62
+ expect do
63
+ expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3)).in_first(4)
64
+ end.to raise_error.with_message a_string_including 'not to include document {"fld"=>["val1", "val2", "val3"]} in first 4'
65
+ end
66
+ it 'passes when include arg is Hash but doc comes too late' do
67
+ expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3)).in_first(2)
68
+ end
69
+ it 'fails when include arg is Array and all docs meet criteria' do
70
+ expect do
71
+ expect(@solr_resp_5_docs).not_to include('111', '222').in_first(2)
72
+ end.to raise_error.with_message a_string_including 'not to include documents "111" and "222" in first 2'
73
+ expect do
74
+ expect(@solr_resp_5_docs).not_to include(['333', { 'fld2' => 'val2' }]).in_first(4)
75
+ end.to raise_error.with_message a_string_including 'not to include documents ["333", {"fld2"=>"val2"}] in first 4'
76
+ end
77
+ it 'passes when include arg is Array but at least one doc comes too late' do
78
+ expect(@solr_resp_5_docs).not_to include(%w(111 444)).in_first(2)
79
+ expect(@solr_resp_5_docs).not_to include(['333', { 'fld2' => 'val2' }]).in_first(2)
80
+ end
81
+ it 'passes when there is no matching result' do
82
+ expect(@solr_resp_5_docs).not_to include('666').in_first(6)
83
+ expect(@solr_resp_5_docs).not_to include('fld' => 'not there').in_first(3)
84
+ expect(@solr_resp_5_docs).not_to include('666', '777').in_first(6)
85
+ end
86
+ end # should_NOT include().in_first(n)
88
87
  end # include().in_first(n)
89
-
90
- context "#include().in_first (no n set) implies n=1" do
91
- context "should #include().in_first" do
92
- it "passes when matching document is first" do
93
- @solr_resp_5_docs.should include("111").in_first
88
+
89
+ context '#include().in_first (no n set) implies n=1' do
90
+ context 'should #include().in_first' do
91
+ it 'passes when matching document is first' do
92
+ expect(@solr_resp_5_docs).to include('111').in_first
94
93
  end
95
- it "fails when matching document is not first" do
96
- lambda {
97
- @solr_resp_5_docs.should include("fld"=>["val1", "val2", "val3"]).in_first
98
- }.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
94
+ it 'fails when matching document is not first' do
95
+ expect do
96
+ expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3)).in_first
97
+ end.to raise_error.with_message a_string_including 'expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1'
99
98
  end
100
99
  end
101
- context "should_NOT include().in_first" do
102
- it "fails when matching document is first" do
103
- lambda {
104
- @solr_resp_5_docs.should_not include("111").in_first
105
- }.should fail_matching('not to include document "111" in first 1')
100
+ context 'should_NOT include().in_first' do
101
+ it 'fails when matching document is first' do
102
+ expect do
103
+ expect(@solr_resp_5_docs).not_to include('111').in_first
104
+ end.to raise_error.with_message a_string_including 'not to include document "111" in first 1'
106
105
  end
107
- it "passes when matching document is not first" do
108
- @solr_resp_5_docs.should_not include("fld"=>["val1", "val2", "val3"]).in_first
106
+ it 'passes when matching document is not first' do
107
+ expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3)).in_first
109
108
  end
110
109
  end
111
110
  end # include().in_first (no n set)
112
-
113
- context "#include().in_first(n).allowed_chained.names" do
114
- context "should #include().in_first(n).allowed_chained.names" do
115
- it "passes when document(s) meet criteria" do
116
- @solr_resp_5_docs.should include("222").in_first(2).results
117
- @solr_resp_5_docs.should include("222").in_first(2).documents
118
- @solr_resp_5_docs.should include("fld2"=>"val2").in_first.document
111
+
112
+ context '#include().in_first(n).allowed_chained.names' do
113
+ context 'should #include().in_first(n).allowed_chained.names' do
114
+ it 'passes when document(s) meet criteria' do
115
+ expect(@solr_resp_5_docs).to include('222').in_first(2).results
116
+ expect(@solr_resp_5_docs).to include('222').in_first(2).documents
117
+ expect(@solr_resp_5_docs).to include('fld2' => 'val2').in_first.document
119
118
  end
120
119
  it "fails when document(s) don't meet criteria" do
121
- lambda {
122
- @solr_resp_5_docs.should include("fld"=>["val1", "val2", "val3"]).in_first.result
123
- }.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
120
+ expect do
121
+ expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3)).in_first.result
122
+ end.to raise_error.with_message a_string_including 'expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1'
124
123
  end
125
124
  end
126
- context "should_NOT #include().in_first(n).allowed_chained.names" do
127
- it "fails when document(s) meet criteria" do
128
- lambda {
129
- @solr_resp_5_docs.should_not include("222").in_first(2).documents
130
- }.should fail_matching('not to include document "222" in first 2 ')
131
- lambda {
132
- @solr_resp_5_docs.should_not include("fld2"=>"val2").in_first.document
133
- }.should fail_matching('not to include document {"fld2"=>"val2"} in first 1')
125
+ context 'should_NOT #include().in_first(n).allowed_chained.names' do
126
+ it 'fails when document(s) meet criteria' do
127
+ expect do
128
+ expect(@solr_resp_5_docs).not_to include('222').in_first(2).documents
129
+ end.to raise_error.with_message a_string_including 'not to include document "222" in first 2 '
130
+ expect do
131
+ expect(@solr_resp_5_docs).not_to include('fld2' => 'val2').in_first.document
132
+ end.to raise_error.with_message a_string_including 'not to include document {"fld2"=>"val2"} in first 1'
134
133
  end
135
134
  it "passes when document(s) don't meet criteria" do
136
- @solr_resp_5_docs.should_not include("fld"=>["val1", "val2", "val3"]).in_first.result
135
+ expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3)).in_first.result
137
136
  end
138
137
  end
139
- it "should raise a NoMethodError exception when it gets nonsense after include" do
140
- expect {
141
- @solr_resp.should include("111").bad_method(2)
142
- }.to raise_error(NoMethodError, /bad_method/)
143
- end
138
+ it 'should raise a NoMethodError exception when it gets nonsense after include' do
139
+ expect do
140
+ expect(@solr_resp).to include('111').bad_method(2)
141
+ end.to raise_error(NoMethodError, /bad_method/)
142
+ end
144
143
  end # include().in_first().allowed_chained.names
145
-
146
- context "#include().as_first" do
147
- context "should include().as_first" do
148
- it "passes when the first document meets the criteria" do
149
- @solr_resp_5_docs.should include("111").as_first
150
- @solr_resp_5_docs.should include("fld"=>"val").as_first
151
- @solr_resp_5_docs.should include("fld"=>"val", "fld2"=>"val2").as_first
152
- end
153
- it "fails when a document meets the criteria but is not the first" do
154
- lambda {
155
- @solr_resp_5_docs.should include("222").as_first
156
- }.should fail_matching('expected response to include document "222" in first 1')
157
- lambda {
158
- @solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"]).as_first
159
- }.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
160
- end
161
- it "fails when there is no matching result" do
162
- lambda {
163
- @solr_resp_5_docs.should include("96").as_first
164
- }.should fail_matching('expected response to include document "96" in first 1')
165
- end
144
+
145
+ context '#include().as_first' do
146
+ context 'should include().as_first' do
147
+ it 'passes when the first document meets the criteria' do
148
+ expect(@solr_resp_5_docs).to include('111').as_first
149
+ expect(@solr_resp_5_docs).to include('fld' => 'val').as_first
150
+ expect(@solr_resp_5_docs).to include('fld' => 'val', 'fld2' => 'val2').as_first
151
+ end
152
+ it 'fails when a document meets the criteria but is not the first' do
153
+ expect do
154
+ expect(@solr_resp_5_docs).to include('222').as_first
155
+ end.to raise_error.with_message a_string_including 'expected response to include document "222" in first 1'
156
+ expect do
157
+ expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3)).as_first
158
+ end.to raise_error.with_message a_string_including 'expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1'
159
+ end
160
+ it 'fails when there is no matching result' do
161
+ expect do
162
+ expect(@solr_resp_5_docs).to include('96').as_first
163
+ end.to raise_error.with_message a_string_including 'expected response to include document "96" in first 1'
164
+ end
166
165
  end
167
- context "should_NOT include().as_first" do
168
- it "fails when the first document meets the criteria" do
169
- lambda {
170
- @solr_resp_5_docs.should_not include("111").as_first
171
- }.should fail_matching('not to include document "111" in first 1')
172
- lambda {
173
- @solr_resp_5_docs.should_not include("fld"=>"val").as_first
174
- }.should fail_matching('not to include document {"fld"=>"val"} in first 1')
175
- lambda {
176
- @solr_resp_5_docs.should_not include("fld"=>"val", "fld2"=>"val2").as_first
177
- }.should fail_matching('not to include document {"fld"=>"val", "fld2"=>"val2"} in first 1')
178
- end
179
- it "passes when a document meets the criteria but is not the first" do
180
- @solr_resp_5_docs.should_not include("222").as_first.document
181
- @solr_resp_5_docs.should_not include("fld" => ["val1", "val2", "val3"]).as_first
182
- end
183
- it "passes when there is no matching result" do
184
- @solr_resp_5_docs.should_not include("96").as_first
185
- end
166
+ context 'should_NOT include().as_first' do
167
+ it 'fails when the first document meets the criteria' do
168
+ expect do
169
+ expect(@solr_resp_5_docs).not_to include('111').as_first
170
+ end.to raise_error.with_message a_string_including 'not to include document "111" in first 1'
171
+ expect do
172
+ expect(@solr_resp_5_docs).not_to include('fld' => 'val').as_first
173
+ end.to raise_error.with_message a_string_including 'not to include document {"fld"=>"val"} in first 1'
174
+ expect do
175
+ expect(@solr_resp_5_docs).not_to include('fld' => 'val', 'fld2' => 'val2').as_first
176
+ end.to raise_error.with_message a_string_including 'not to include document {"fld"=>"val", "fld2"=>"val2"} in first 1'
177
+ end
178
+ it 'passes when a document meets the criteria but is not the first' do
179
+ expect(@solr_resp_5_docs).not_to include('222').as_first.document
180
+ expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3)).as_first
181
+ end
182
+ it 'passes when there is no matching result' do
183
+ expect(@solr_resp_5_docs).not_to include('96').as_first
184
+ end
186
185
  end
187
186
  end
188
-
189
-
190
- context "#include().as_first().allowed_chained.names" do
191
- context "should #include().as_first(n).allowed_chained.names" do
192
- it "passes when document(s) meet criteria" do
193
- @solr_resp_5_docs.should include(["111", "222"]).as_first(2).results
194
- @solr_resp_5_docs.should include(["111", "222"]).as_first(2).documents
195
- @solr_resp_5_docs.should include("fld2"=>"val2").as_first.document
187
+
188
+ context '#include().as_first().allowed_chained.names' do
189
+ context 'should #include().as_first(n).allowed_chained.names' do
190
+ it 'passes when document(s) meet criteria' do
191
+ expect(@solr_resp_5_docs).to include(%w(111 222)).as_first(2).results
192
+ expect(@solr_resp_5_docs).to include(%w(111 222)).as_first(2).documents
193
+ expect(@solr_resp_5_docs).to include('fld2' => 'val2').as_first.document
196
194
  end
197
195
  it "fails when document(s) don't meet criteria" do
198
- lambda {
199
- @solr_resp_5_docs.should include("fld"=>["val1", "val2", "val3"]).as_first.result
200
- }.should fail_matching ('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
196
+ expect do
197
+ expect(@solr_resp_5_docs).to include('fld' => %w(val1 val2 val3)).as_first.result
198
+ end.to raise_error.with_message a_string_including 'expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1'
201
199
  end
202
200
  end
203
- context "should_NOT #include().as_first(n).any_chained.names" do
204
- it "fails when document(s) meet criteria" do
205
- lambda {
206
- @solr_resp_5_docs.should_not include(["111", "222"]).as_first(2).documents
207
- }.should fail_matching('not to include documents ["111", "222"] in first 2')
208
- lambda {
209
- @solr_resp_5_docs.should_not include("fld2"=>"val2").as_first.document
210
- }.should fail_matching('not to include document {"fld2"=>"val2"} in first 1')
201
+ context 'should_NOT #include().as_first(n).any_chained.names' do
202
+ it 'fails when document(s) meet criteria' do
203
+ expect do
204
+ expect(@solr_resp_5_docs).not_to include(%w(111 222)).as_first(2).documents
205
+ end.to raise_error.with_message a_string_including 'not to include documents ["111", "222"] in first 2'
206
+ expect do
207
+ expect(@solr_resp_5_docs).not_to include('fld2' => 'val2').as_first.document
208
+ end.to raise_error.with_message a_string_including 'not to include document {"fld2"=>"val2"} in first 1'
211
209
  end
212
210
  it "passes when document(s) don't meet criteria" do
213
- @solr_resp_5_docs.should_not include("fld"=>["val1", "val2", "val3"]).as_first.result
211
+ expect(@solr_resp_5_docs).not_to include('fld' => %w(val1 val2 val3)).as_first.result
214
212
  end
215
213
  end
216
214
  end # include().as_first().allowed_chained.names
217
215
 
218
216
  before(:all) do
219
- @solr_resp_5_docs = RSpecSolr::SolrResponseHash.new({ "response" =>
220
- { "numFound" => 5,
221
- "start" => 0,
222
- "docs" =>
223
- [ {"id"=>"111", "fld"=>"val", "fld2"=>"val2"},
224
- {"id"=>"222"},
225
- {"id"=>"333", "fld"=>"val"},
226
- {"id"=>"444", "fld"=>["val1", "val2", "val3"]},
227
- {"id"=>"555"}
217
+ @solr_resp_5_docs = RSpecSolr::SolrResponseHash.new('response' =>
218
+ { 'numFound' => 5,
219
+ 'start' => 0,
220
+ 'docs' =>
221
+ [{ 'id' => '111', 'fld' => 'val', 'fld2' => 'val2' },
222
+ { 'id' => '222' },
223
+ { 'id' => '333', 'fld' => 'val' },
224
+ { 'id' => '444', 'fld' => %w(val1 val2 val3) },
225
+ { 'id' => '555' }
228
226
  ]
229
- }
230
- })
227
+ })
231
228
  end
232
-
233
- end
229
+ end