rspec-solr 0.1.4 → 0.2.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.
- data/MATCHERS.rdoc +20 -16
- data/README.rdoc +18 -11
- data/lib/rspec-solr.rb +1 -0
- data/lib/rspec-solr/have_facet_field_matcher.rb +69 -0
- data/lib/rspec-solr/include_documents_matcher.rb +4 -4
- data/lib/rspec-solr/solr_response_hash.rb +24 -1
- data/lib/rspec-solr/version.rb +1 -1
- data/spec/have_facet_field_spec.rb +101 -0
- data/spec/include_before_spec.rb +6 -6
- data/spec/include_in_first_n_spec.rb +13 -13
- metadata +7 -4
data/MATCHERS.rdoc
CHANGED
@@ -50,7 +50,8 @@
|
|
50
50
|
* ("fldname" => ["val1", /val2_regex/, "val3"])
|
51
51
|
NOTE: all of the Array values must be present for the fld in a single Solr document
|
52
52
|
should_not for Array implies NONE of the values should be present in a single document
|
53
|
-
|
53
|
+
|
54
|
+
More Ideas (TODO):
|
54
55
|
* include_title("val") (i.e. include_anyFieldName("val") )
|
55
56
|
|
56
57
|
==== Specifying Multiple Documents
|
@@ -144,22 +145,25 @@ TODO: Potential Syntax:
|
|
144
145
|
* rspec-solr_resp_hash1.size.should == rspec-solr_resp_hash2.size
|
145
146
|
* rspec-solr_resp_hash1.size.should be_within(delta).of(rspec-solr_resp_hash2.size)
|
146
147
|
|
147
|
-
==
|
148
|
-
|
149
|
-
NOTE: this is about the facet values returned in THIS response
|
148
|
+
== MATCHING FACET VALUES IN RESPONSE
|
150
149
|
|
151
|
-
|
152
|
-
* facet(:format => "Book")
|
153
|
-
* facets(:format => ["Image", "Map"])
|
154
|
-
* facets with arrarr and without
|
155
|
-
|
156
|
-
=== Potential Syntax
|
157
|
-
rspec-solr_resp_hash.should include_facet
|
150
|
+
NOTE: this is about the facet counts returned in THIS response
|
158
151
|
|
159
152
|
=== Matchers
|
160
|
-
*
|
161
|
-
*
|
162
|
-
* include_facet().before_facets()
|
163
|
-
* include_facets().before_facets()
|
164
|
-
|
153
|
+
* have_facet_field()
|
154
|
+
* have_facet_field().with_value()
|
165
155
|
|
156
|
+
=== Usage
|
157
|
+
* rspec-solr_resp_hash.should have_facet_field("author")
|
158
|
+
* rspec-solr_resp_hash.should have_facet_field("author").with_value("Steinbeck, John")
|
159
|
+
|
160
|
+
=== TODO:
|
161
|
+
* facets with arrarr and without (Solr option to get better facet formatting)
|
162
|
+
* have_facet_field().with_value().with_count()
|
163
|
+
* more ideas
|
164
|
+
** facet(:format => "Book")
|
165
|
+
** facets(:format => ["Image", "Map"])
|
166
|
+
** include_facet().before_facet()
|
167
|
+
** include_facets().before_facet()
|
168
|
+
** include_facet().before_facets()
|
169
|
+
** include_facets().before_facets()
|
data/README.rdoc
CHANGED
@@ -31,7 +31,7 @@ See MATCHERS.rdoc for syntax of supported expectations.
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "q of 'Two3' should have excellent results", :jira => 'VUF-386' do
|
34
|
-
resp =
|
34
|
+
resp = solr_response({'q'=>'Two3', 'fl'=>'id', 'facet'=>false})
|
35
35
|
resp.should have_at_most(10).documents
|
36
36
|
resp.should include("5732752").as_first_result
|
37
37
|
resp.should include("8564713").in_first(2).results
|
@@ -41,7 +41,7 @@ See MATCHERS.rdoc for syntax of supported expectations.
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "Traditional Chinese chars 三國誌 should get the same results as simplified chars 三国志" do
|
44
|
-
|
44
|
+
resp = solr_response({'q'=>'三國誌', 'fl'=>'id', 'facet'=>false})
|
45
45
|
resp.should have_at_least(240).documents
|
46
46
|
resp.should have_the_same_number_of_results_as(solr_resp_doc_ids_only({'q'=>'三国志'}))
|
47
47
|
end
|
@@ -101,14 +101,6 @@ Do a one time setup of Solr connection, and methods to make it easier to make de
|
|
101
101
|
puts "Solr URL: #{@@solr.uri}"
|
102
102
|
end
|
103
103
|
|
104
|
-
# send a GET request to the default Solr request handler with the indicated Solr parameters
|
105
|
-
# @param solr_params [Hash] the key/value pairs to be sent to Solr as HTTP parameters, in addition to
|
106
|
-
# those to get only id fields and no facets in the response
|
107
|
-
# @return [RSpecSolr::SolrResponseHash] object for rspec-solr testing the Solr response
|
108
|
-
def solr_resp_doc_ids_only(solr_params)
|
109
|
-
solr_response(solr_params.merge(@@doc_ids_only))
|
110
|
-
end
|
111
|
-
|
112
104
|
private
|
113
105
|
|
114
106
|
# send a GET request to the indicated Solr request handler with the indicated Solr parameters
|
@@ -118,6 +110,17 @@ Do a one time setup of Solr connection, and methods to make it easier to make de
|
|
118
110
|
def solr_response(solr_params, req_handler='select')
|
119
111
|
RSpecSolr::SolrResponseHash.new(@@solr.send_and_receive(req_handler, {:method => :get, :params => solr_params}))
|
120
112
|
end
|
113
|
+
|
114
|
+
===== 4a. a little more magic
|
115
|
+
You might want to add code such as that below to your spec_helper - it can help keep your solr responses small, which makes for easier debugging.
|
116
|
+
|
117
|
+
# send a GET request to the default Solr request handler with the indicated Solr parameters
|
118
|
+
# @param solr_params [Hash] the key/value pairs to be sent to Solr as HTTP parameters, in addition to
|
119
|
+
# those to get only id fields and no facets in the response
|
120
|
+
# @return [RSpecSolr::SolrResponseHash] object for rspec-solr testing the Solr response
|
121
|
+
def solr_resp_doc_ids_only(solr_params)
|
122
|
+
solr_response(solr_params.merge(@@doc_ids_only))
|
123
|
+
end
|
121
124
|
|
122
125
|
# use these Solr HTTP params to reduce the size of the Solr responses
|
123
126
|
# response documents will only have id fields, and there will be no facets in the response
|
@@ -146,5 +149,9 @@ Please share yours!
|
|
146
149
|
5. Create new Pull Request
|
147
150
|
|
148
151
|
== Releases
|
149
|
-
-
|
152
|
+
- <b>0.2.0</b> add facet support have_facet_field(fld_name).with_value(fld_value)
|
153
|
+
- <b>0.1.4</b> fix regex match to work with in_each_of_first(n)
|
154
|
+
- <b>0.1.3</b> added include().in_each_of_first(n)
|
155
|
+
- <b>0.1.2</b> added document matching via regex for field values
|
156
|
+
- <b>0.1.1</b> improve README
|
150
157
|
- <b>0.1.0</b> Initial release
|
data/lib/rspec-solr.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Custom RSpec Matchers for Solr responses
|
2
|
+
module RSpecSolr::Matchers
|
3
|
+
|
4
|
+
# Determine if the receiver has the facet_field
|
5
|
+
def have_facet_field
|
6
|
+
# Placeholder method for documentation purposes;
|
7
|
+
# the actual method is defined using RSpec's matcher DSL
|
8
|
+
end
|
9
|
+
|
10
|
+
# this is the lambda used to determine if the receiver (a Solr response object) has non-empty values for the facet field
|
11
|
+
# as the expected RSpecSolr::SolrResponseHash
|
12
|
+
def self.have_facet_field_body
|
13
|
+
lambda { |expected_facet_field_name|
|
14
|
+
|
15
|
+
match_for_should do |solr_resp|
|
16
|
+
if @facet_val
|
17
|
+
solr_resp.has_facet_field_with_value?(expected_facet_field_name, @facet_val)
|
18
|
+
else
|
19
|
+
solr_resp.has_facet_field?(expected_facet_field_name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
match_for_should_not do |solr_resp|
|
24
|
+
# we should fail if we are looking for a specific facet value but the facet field isn't present in the response
|
25
|
+
@has_field = solr_resp.has_facet_field?(expected_facet_field_name)
|
26
|
+
if @facet_val
|
27
|
+
if @has_field
|
28
|
+
!solr_resp.has_facet_field_with_value?(expected_facet_field_name, @facet_val)
|
29
|
+
else
|
30
|
+
false
|
31
|
+
end
|
32
|
+
else
|
33
|
+
!@has_field
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
failure_message_for_should do |solr_resp|
|
38
|
+
if @facet_val
|
39
|
+
"expected facet field #{expected_facet_field_name} with value #{@facet_val} in Solr response: #{solr_resp}"
|
40
|
+
else
|
41
|
+
"expected facet field #{expected_facet_field_name} with values in Solr response: #{solr_resp}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
failure_message_for_should_not do |solr_resp|
|
46
|
+
if @facet_val
|
47
|
+
if @has_field
|
48
|
+
"expected facet field #{expected_facet_field_name} not to have value #{@facet_val} in Solr response: #{solr_resp}"
|
49
|
+
else
|
50
|
+
"expected facet field #{expected_facet_field_name} in Solr response: #{solr_resp}"
|
51
|
+
end
|
52
|
+
else
|
53
|
+
"expected no #{expected_facet_field_name} facet field in Solr response: #{solr_resp}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
chain :with_value do |val|
|
58
|
+
@facet_val = val
|
59
|
+
end
|
60
|
+
|
61
|
+
diffable
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# Determine if the receiver (a Solr response object) has the same number of total documents as the expected RSpecSolr::SolrResponseHash
|
66
|
+
# NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
|
67
|
+
RSpec::Matchers.define :have_facet_field, &have_facet_field_body
|
68
|
+
|
69
|
+
end
|
@@ -37,11 +37,11 @@ module RSpec
|
|
37
37
|
assert_ivars :@actual, :@expected
|
38
38
|
# FIXME: DRY up these messages across cases and across should and should_not
|
39
39
|
if @before_expected
|
40
|
-
"expected
|
40
|
+
"expected response to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} before #{doc_label_str(@before_expected)} matching #{@before_expected.inspect}: #{@actual.inspect} "
|
41
41
|
elsif @min_for_last_matching_doc_pos
|
42
42
|
"expected each of the first #{@min_for_last_matching_doc_pos.to_s} documents to #{name_to_sentence}#{expected_to_sentence} in response: #{@actual.inspect}"
|
43
43
|
elsif @max_doc_position
|
44
|
-
"expected
|
44
|
+
"expected response to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} in first #{@max_doc_position.to_s} results: #{@actual.inspect}"
|
45
45
|
else
|
46
46
|
super
|
47
47
|
end
|
@@ -51,11 +51,11 @@ module RSpec
|
|
51
51
|
def failure_message_for_should_not
|
52
52
|
assert_ivars :@actual, :@expected
|
53
53
|
if @before_expected
|
54
|
-
"expected
|
54
|
+
"expected response not to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} before #{doc_label_str(@before_expected)} matching #{@before_expected.inspect}: #{@actual.inspect} "
|
55
55
|
elsif @min_for_last_matching_doc_pos
|
56
56
|
"expected some of the first #{@min_for_last_matching_doc_pos.to_s} documents not to #{name_to_sentence}#{expected_to_sentence} in response: #{@actual.inspect}"
|
57
57
|
elsif @max_doc_position
|
58
|
-
"expected
|
58
|
+
"expected response not to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} in first #{@max_doc_position.to_s} results: #{@actual.inspect}"
|
59
59
|
else
|
60
60
|
super
|
61
61
|
end
|
@@ -74,7 +74,7 @@ class RSpecSolr
|
|
74
74
|
# a doc's fld values can be a String or an Array
|
75
75
|
case exp_val
|
76
76
|
when Regexp
|
77
|
-
|
77
|
+
Array(doc[exp_fname]).any? { |val| val =~ exp_val }
|
78
78
|
else
|
79
79
|
Array(doc[exp_fname]).include?(exp_val)
|
80
80
|
end
|
@@ -133,6 +133,29 @@ class RSpecSolr
|
|
133
133
|
(self['response'] ? "'response' => {'numFound' => #{self['response']['numFound']}, ...}" : "" ) +
|
134
134
|
" ... }"
|
135
135
|
end
|
136
|
+
|
137
|
+
# @return true if the Solr response contains the facet field indicated and the facet field has some values; return false otherwise
|
138
|
+
def has_facet_field_with_value?(ff_name, facet_val = nil)
|
139
|
+
if self["facet_counts"] && self["facet_counts"]["facet_fields"] && self["facet_counts"]["facet_fields"][ff_name]
|
140
|
+
if facet_val
|
141
|
+
val_count_array = self["facet_counts"]["facet_fields"][ff_name]
|
142
|
+
return val_count_array.each_slice(2).find { |val_count| val_count[0] == facet_val}
|
143
|
+
else
|
144
|
+
self["facet_counts"]["facet_fields"][ff_name].size > 0
|
145
|
+
end
|
146
|
+
else
|
147
|
+
false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# @return true if the Solr response contains the facet field indicated and the facet field has some values; return false otherwise
|
152
|
+
def has_facet_field?(ff_name)
|
153
|
+
if self["facet_counts"] && self["facet_counts"]["facet_fields"] && self["facet_counts"]["facet_fields"][ff_name]
|
154
|
+
self["facet_counts"]["facet_fields"][ff_name]
|
155
|
+
else
|
156
|
+
false
|
157
|
+
end
|
158
|
+
end
|
136
159
|
|
137
160
|
private
|
138
161
|
|
data/lib/rspec-solr/version.rb
CHANGED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec-solr'
|
3
|
+
|
4
|
+
describe RSpecSolr do
|
5
|
+
|
6
|
+
# 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')
|
11
|
+
end
|
12
|
+
it "passes if response has facet field but no values" do
|
13
|
+
@solr_resp_w_facets.should have_facet_field('ff3')
|
14
|
+
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: ")
|
19
|
+
end
|
20
|
+
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: ")
|
30
|
+
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: ")
|
35
|
+
end
|
36
|
+
it "passes if response does not have the facet field" do
|
37
|
+
@solr_resp_w_facets.should_not have_facet_field('ff4')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
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')
|
44
|
+
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")
|
49
|
+
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")
|
54
|
+
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")
|
59
|
+
end
|
60
|
+
|
61
|
+
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")
|
67
|
+
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')
|
70
|
+
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')
|
73
|
+
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")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
before(:all) do
|
83
|
+
@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
|
+
})
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/spec/include_before_spec.rb
CHANGED
@@ -20,28 +20,28 @@ describe RSpecSolr do
|
|
20
20
|
it "fails when docs aren't in expected order" do
|
21
21
|
lambda {
|
22
22
|
@solr_resp_5_docs.should include("222").before("fld2"=>"val2")
|
23
|
-
}.should fail_matching('
|
23
|
+
}.should fail_matching('expected response to include document "222" before document matching {"fld2"=>"val2"}')
|
24
24
|
lambda {
|
25
25
|
@solr_resp_5_docs.should include("111", "444").before([{"id"=>"333"}, {"id"=>"555"}])
|
26
|
-
}.should fail_matching('
|
26
|
+
}.should fail_matching('expected response to include documents "111" and "444" before documents matching [{"id"=>"333"}, {"id"=>"555"}]')
|
27
27
|
lambda {
|
28
28
|
@solr_resp_5_docs.should include([{"id"=>"222"}, {"id"=>"444"}]).before([{"id"=>"333"}, {"id"=>"555"}])
|
29
|
-
}.should fail_matching('
|
29
|
+
}.should fail_matching('expected response to include documents [{"id"=>"222"}, {"id"=>"444"}] before documents matching [{"id"=>"333"}, {"id"=>"555"}]')
|
30
30
|
end
|
31
31
|
it "fails when it can't find a doc matching first argument(s)" do
|
32
32
|
lambda {
|
33
33
|
@solr_resp_5_docs.should include("not_there").before("555")
|
34
|
-
}.should fail_matching('
|
34
|
+
}.should fail_matching('expected response to include document "not_there" before document matching "555"')
|
35
35
|
end
|
36
36
|
it "fails when it can't find a doc matching second argument(s)" do
|
37
37
|
lambda {
|
38
38
|
@solr_resp_5_docs.should include("222").before("not_there")
|
39
|
-
}.should fail_matching('
|
39
|
+
}.should fail_matching('expected response to include document "222" before document matching "not_there"')
|
40
40
|
end
|
41
41
|
it "fails when it can't find docs matching first or second argument(s)" do
|
42
42
|
lambda {
|
43
43
|
@solr_resp_5_docs.should include("not_there").before("still_not_there")
|
44
|
-
}.should fail_matching('
|
44
|
+
}.should fail_matching('expected response to include document "not_there" before document matching "still_not_there"')
|
45
45
|
end
|
46
46
|
|
47
47
|
end # should include().before()
|
@@ -15,7 +15,7 @@ describe RSpecSolr do
|
|
15
15
|
it "fails when include arg is String but doc comes too late" do
|
16
16
|
lambda {
|
17
17
|
@solr_resp_5_docs.should include("222").in_first(1)
|
18
|
-
}.should fail_matching('
|
18
|
+
}.should fail_matching('expected response to include document "222" in first 1')
|
19
19
|
end
|
20
20
|
it "passes when include arg is Hash and doc meets criteria" do
|
21
21
|
@solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"]).in_first(4)
|
@@ -23,7 +23,7 @@ describe RSpecSolr do
|
|
23
23
|
it "fails when include arg is Hash but doc comes too late" do
|
24
24
|
lambda {
|
25
25
|
@solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"]).in_first(2)
|
26
|
-
}.should fail_matching('
|
26
|
+
}.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 2')
|
27
27
|
end
|
28
28
|
it "passes when include arg is Array and all docs meet criteria" do
|
29
29
|
@solr_resp_5_docs.should include(["111", "222"]).in_first(2)
|
@@ -32,21 +32,21 @@ describe RSpecSolr do
|
|
32
32
|
it "fails when include arg is Array but at least one doc comes too late" do
|
33
33
|
lambda {
|
34
34
|
@solr_resp_5_docs.should include(["111", "444"]).in_first(2)
|
35
|
-
}.should fail_matching('
|
35
|
+
}.should fail_matching('expected response to include documents ["111", "444"] in first 2')
|
36
36
|
lambda {
|
37
37
|
@solr_resp_5_docs.should include(["333", {"fld2"=>"val2"}]).in_first(2)
|
38
|
-
}.should fail_matching('
|
38
|
+
}.should fail_matching('expected response to include documents ["333", {"fld2"=>"val2"}] in first 2')
|
39
39
|
end
|
40
40
|
it "fails when there is no matching result" do
|
41
41
|
lambda {
|
42
42
|
@solr_resp_5_docs.should include("666").in_first(6)
|
43
|
-
}.should fail_matching('
|
43
|
+
}.should fail_matching('expected response to include document "666" in first 6')
|
44
44
|
lambda {
|
45
45
|
@solr_resp_5_docs.should include("fld"=>"not there").in_first(3)
|
46
|
-
}.should fail_matching('
|
46
|
+
}.should fail_matching('expected response to include document {"fld"=>"not there"} in first 3')
|
47
47
|
lambda {
|
48
48
|
@solr_resp_5_docs.should include("666", "777").in_first(6)
|
49
|
-
}.should fail_matching('
|
49
|
+
}.should fail_matching('expected response to include documents "666" and "777" in first 6')
|
50
50
|
end
|
51
51
|
end # should include().in_first(n)
|
52
52
|
|
@@ -95,7 +95,7 @@ describe RSpecSolr do
|
|
95
95
|
it "fails when matching document is not first" do
|
96
96
|
lambda {
|
97
97
|
@solr_resp_5_docs.should include("fld"=>["val1", "val2", "val3"]).in_first
|
98
|
-
}.should fail_matching('
|
98
|
+
}.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
|
99
99
|
end
|
100
100
|
end
|
101
101
|
context "should_NOT include().in_first" do
|
@@ -120,7 +120,7 @@ describe RSpecSolr do
|
|
120
120
|
it "fails when document(s) don't meet criteria" do
|
121
121
|
lambda {
|
122
122
|
@solr_resp_5_docs.should include("fld"=>["val1", "val2", "val3"]).in_first.result
|
123
|
-
}.should fail_matching('
|
123
|
+
}.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
|
124
124
|
end
|
125
125
|
end
|
126
126
|
context "should_NOT #include().in_first(n).allowed_chained.names" do
|
@@ -153,15 +153,15 @@ describe RSpecSolr do
|
|
153
153
|
it "fails when a document meets the criteria but is not the first" do
|
154
154
|
lambda {
|
155
155
|
@solr_resp_5_docs.should include("222").as_first
|
156
|
-
}.should fail_matching('
|
156
|
+
}.should fail_matching('expected response to include document "222" in first 1')
|
157
157
|
lambda {
|
158
158
|
@solr_resp_5_docs.should include("fld" => ["val1", "val2", "val3"]).as_first
|
159
|
-
}.should fail_matching('
|
159
|
+
}.should fail_matching('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
|
160
160
|
end
|
161
161
|
it "fails when there is no matching result" do
|
162
162
|
lambda {
|
163
163
|
@solr_resp_5_docs.should include("96").as_first
|
164
|
-
}.should fail_matching('
|
164
|
+
}.should fail_matching('expected response to include document "96" in first 1')
|
165
165
|
end
|
166
166
|
end
|
167
167
|
context "should_NOT include().as_first" do
|
@@ -197,7 +197,7 @@ describe RSpecSolr do
|
|
197
197
|
it "fails when document(s) don't meet criteria" do
|
198
198
|
lambda {
|
199
199
|
@solr_resp_5_docs.should include("fld"=>["val1", "val2", "val3"]).as_first.result
|
200
|
-
}.should fail_matching ('
|
200
|
+
}.should fail_matching ('expected response to include document {"fld"=>["val1", "val2", "val3"]} in first 1')
|
201
201
|
end
|
202
202
|
end
|
203
203
|
context "should_NOT #include().as_first(n).any_chained.names" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-solr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/rspec-solr.rb
|
148
148
|
- lib/rspec-solr/compare_num_docs_matcher.rb
|
149
149
|
- lib/rspec-solr/have_documents_matcher.rb
|
150
|
+
- lib/rspec-solr/have_facet_field_matcher.rb
|
150
151
|
- lib/rspec-solr/include_documents_matcher.rb
|
151
152
|
- lib/rspec-solr/solr_response_hash.rb
|
152
153
|
- lib/rspec-solr/version.rb
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- rspec-solr.gemspec
|
157
158
|
- spec/comparing_num_docs_in_2_resp_spec.rb
|
158
159
|
- spec/have_documents_spec.rb
|
160
|
+
- spec/have_facet_field_spec.rb
|
159
161
|
- spec/include_before_spec.rb
|
160
162
|
- spec/include_document_spec.rb
|
161
163
|
- spec/include_in_each_of_first_n_spec.rb
|
@@ -178,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
180
|
version: '0'
|
179
181
|
segments:
|
180
182
|
- 0
|
181
|
-
hash:
|
183
|
+
hash: -4309993741497496154
|
182
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
185
|
none: false
|
184
186
|
requirements:
|
@@ -187,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
189
|
version: '0'
|
188
190
|
segments:
|
189
191
|
- 0
|
190
|
-
hash:
|
192
|
+
hash: -4309993741497496154
|
191
193
|
requirements: []
|
192
194
|
rubyforge_project:
|
193
195
|
rubygems_version: 1.8.24
|
@@ -197,6 +199,7 @@ summary: RSpec custom matchers for Solr response objects
|
|
197
199
|
test_files:
|
198
200
|
- spec/comparing_num_docs_in_2_resp_spec.rb
|
199
201
|
- spec/have_documents_spec.rb
|
202
|
+
- spec/have_facet_field_spec.rb
|
200
203
|
- spec/include_before_spec.rb
|
201
204
|
- spec/include_document_spec.rb
|
202
205
|
- spec/include_in_each_of_first_n_spec.rb
|