rspec-solr 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +53 -0
- data/.travis.yml +1 -3
- data/.yardopts +1 -1
- data/Gemfile +2 -0
- data/MATCHERS.md +168 -0
- data/{README.rdoc → README.md} +31 -26
- data/Rakefile +4 -4
- data/lib/rspec-solr.rb +6 -7
- data/lib/rspec-solr/compare_num_docs_matcher.rb +32 -49
- data/lib/rspec-solr/have_documents_matcher.rb +10 -19
- data/lib/rspec-solr/have_facet_field_matcher.rb +16 -24
- data/lib/rspec-solr/include_documents_matcher.rb +65 -46
- data/lib/rspec-solr/solr_response_hash.rb +52 -55
- data/lib/rspec-solr/version.rb +1 -1
- data/lib/tasks/ci.rake +4 -4
- data/lib/tasks/doc.rake +8 -8
- data/lib/tasks/spec.rake +1 -1
- data/rspec-solr.gemspec +20 -20
- data/spec/comparing_num_docs_in_2_resp_spec.rb +205 -217
- data/spec/have_documents_spec.rb +37 -39
- data/spec/have_facet_field_spec.rb +69 -74
- data/spec/include_before_spec.rb +69 -77
- data/spec/include_document_spec.rb +317 -340
- data/spec/include_in_each_of_first_n_spec.rb +76 -79
- data/spec/include_in_first_n_spec.rb +188 -192
- data/spec/number_of_documents_spec.rb +192 -201
- data/spec/solr_response_hash_spec.rb +85 -92
- data/spec/spec_helper.rb +5 -16
- metadata +44 -31
- data/MATCHERS.rdoc +0 -169
- data/spec/support/matchers.rb +0 -22
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,11 @@
|
|
1
1
|
# for test coverage
|
2
|
+
|
3
|
+
require 'rspec-solr'
|
2
4
|
require 'simplecov'
|
3
|
-
require '
|
4
|
-
class SimpleCov::Formatter::MergedFormatter
|
5
|
-
def format(result)
|
6
|
-
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
7
|
-
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
11
|
-
SimpleCov.start do
|
12
|
-
add_filter "/spec/"
|
13
|
-
end
|
5
|
+
require 'rspec/collection_matchers'
|
14
6
|
|
15
7
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
8
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#RSpec.configure do |config|
|
22
|
-
#end
|
10
|
+
RSpec.configure do |_config|
|
11
|
+
end
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
@@ -9,104 +9,118 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec-collection_matchers
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
19
33
|
- !ruby/object:Gem::Version
|
20
34
|
version: '0'
|
21
35
|
type: :runtime
|
22
36
|
prerelease: false
|
23
37
|
version_requirements: !ruby/object:Gem::Requirement
|
24
38
|
requirements:
|
25
|
-
- -
|
39
|
+
- - ">="
|
26
40
|
- !ruby/object:Gem::Version
|
27
41
|
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: rake
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
|
-
- -
|
46
|
+
- - ">="
|
33
47
|
- !ruby/object:Gem::Version
|
34
48
|
version: '0'
|
35
49
|
type: :development
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
|
-
- -
|
53
|
+
- - ">="
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: '0'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: rdoc
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
|
-
- -
|
60
|
+
- - ">="
|
47
61
|
- !ruby/object:Gem::Version
|
48
62
|
version: '0'
|
49
63
|
type: :development
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
|
-
- -
|
67
|
+
- - ">="
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '0'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: yard
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
59
73
|
requirements:
|
60
|
-
- -
|
74
|
+
- - ">="
|
61
75
|
- !ruby/object:Gem::Version
|
62
76
|
version: '0'
|
63
77
|
type: :development
|
64
78
|
prerelease: false
|
65
79
|
version_requirements: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
|
-
- -
|
81
|
+
- - ">="
|
68
82
|
- !ruby/object:Gem::Version
|
69
83
|
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: simplecov
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
|
-
- -
|
88
|
+
- - ">="
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: '0'
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
|
-
- -
|
95
|
+
- - ">="
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
99
|
+
name: travis-lint
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
|
-
- -
|
102
|
+
- - ">="
|
89
103
|
- !ruby/object:Gem::Version
|
90
104
|
version: '0'
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- -
|
109
|
+
- - ">="
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: '0'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
113
|
+
name: rubocop
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
|
-
- -
|
116
|
+
- - ">="
|
103
117
|
- !ruby/object:Gem::Version
|
104
118
|
version: '0'
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
|
-
- -
|
123
|
+
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
112
126
|
description: Provides RSpec custom matchers to be used with Solr response objects.
|
@@ -117,16 +131,17 @@ executables: []
|
|
117
131
|
extensions: []
|
118
132
|
extra_rdoc_files:
|
119
133
|
- LICENSE.txt
|
120
|
-
- README.
|
121
|
-
- MATCHERS.
|
134
|
+
- README.md
|
135
|
+
- MATCHERS.md
|
122
136
|
files:
|
123
|
-
- .gitignore
|
124
|
-
- .
|
125
|
-
- .
|
137
|
+
- ".gitignore"
|
138
|
+
- ".rubocop.yml"
|
139
|
+
- ".travis.yml"
|
140
|
+
- ".yardopts"
|
126
141
|
- Gemfile
|
127
142
|
- LICENSE.txt
|
128
|
-
- MATCHERS.
|
129
|
-
- README.
|
143
|
+
- MATCHERS.md
|
144
|
+
- README.md
|
130
145
|
- Rakefile
|
131
146
|
- lib/rspec-solr.rb
|
132
147
|
- lib/rspec-solr/compare_num_docs_matcher.rb
|
@@ -149,27 +164,26 @@ files:
|
|
149
164
|
- spec/number_of_documents_spec.rb
|
150
165
|
- spec/solr_response_hash_spec.rb
|
151
166
|
- spec/spec_helper.rb
|
152
|
-
- spec/support/matchers.rb
|
153
167
|
homepage: http://github.com/sul-dlss/rspec-solr
|
154
168
|
licenses: []
|
155
169
|
metadata: {}
|
156
170
|
post_install_message:
|
157
171
|
rdoc_options: []
|
158
172
|
require_paths:
|
159
|
-
-
|
173
|
+
- lib
|
160
174
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
175
|
requirements:
|
162
|
-
- -
|
176
|
+
- - ">="
|
163
177
|
- !ruby/object:Gem::Version
|
164
178
|
version: '0'
|
165
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
180
|
requirements:
|
167
|
-
- -
|
181
|
+
- - ">="
|
168
182
|
- !ruby/object:Gem::Version
|
169
183
|
version: '0'
|
170
184
|
requirements: []
|
171
185
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.4.5
|
173
187
|
signing_key:
|
174
188
|
specification_version: 4
|
175
189
|
summary: RSpec custom matchers for Solr response objects
|
@@ -184,5 +198,4 @@ test_files:
|
|
184
198
|
- spec/number_of_documents_spec.rb
|
185
199
|
- spec/solr_response_hash_spec.rb
|
186
200
|
- spec/spec_helper.rb
|
187
|
-
- spec/support/matchers.rb
|
188
201
|
has_rdoc:
|
data/MATCHERS.rdoc
DELETED
@@ -1,169 +0,0 @@
|
|
1
|
-
= RSpec-Solr Matchers for RSpec-Solr::SolrResponseHash
|
2
|
-
|
3
|
-
(rspec-solr_resp_hash..should ... or rspec-solr_resp_hash..should_not ...)
|
4
|
-
|
5
|
-
== MATCHING WHETHER RESPONSE HAS DOCUMENTS OR NOT
|
6
|
-
|
7
|
-
NOTE: this is about the TOTAL number of Solr documents that match ("numFound"), NOT solely the documents returned in this response
|
8
|
-
|
9
|
-
=== Matcher
|
10
|
-
* have_documents
|
11
|
-
|
12
|
-
=== Usage
|
13
|
-
* rspec-solr_resp_hash.should have_documents
|
14
|
-
* rspec-solr_resp_hash.should_not have_documents
|
15
|
-
|
16
|
-
== MATCHING NUMBER OF DOCUMENTS
|
17
|
-
|
18
|
-
NOTE: this is about the TOTAL number of Solr documents that match ("numFound"), NOT solely the documents returned in this response
|
19
|
-
|
20
|
-
=== Matchers
|
21
|
-
* have(2).documents
|
22
|
-
* have_exactly(4).documents
|
23
|
-
* have_at_least(3).documents
|
24
|
-
* have_at_most(3).documents
|
25
|
-
|
26
|
-
=== Usage
|
27
|
-
* rspec-solr_resp_hash.should have(3).documents
|
28
|
-
* rspec-solr_resp_hash.should_not have(2).documents
|
29
|
-
* rspec-solr_resp_hash.should have_at_least(3).documents
|
30
|
-
* rspec-solr_resp_hash.should have_at_most(4).documents
|
31
|
-
|
32
|
-
== MATCHING SPECIFIC DOCUMENTS IN RESPONSE
|
33
|
-
|
34
|
-
NOTE: this is about the Solr documents returned in THIS response
|
35
|
-
|
36
|
-
=== Matcher
|
37
|
-
* include()
|
38
|
-
|
39
|
-
=== Usage
|
40
|
-
==== Specifying Single Document
|
41
|
-
===== String
|
42
|
-
* ("idval")
|
43
|
-
NOTE: value of the unique id field (defaults to 'id') in the Solr document
|
44
|
-
To change the id field name, use my_solr_response_hash.id_field='my_id_fldname'
|
45
|
-
===== Hash
|
46
|
-
* ("fldname" => "value")
|
47
|
-
* ("fldname" => /regex_to_match_val/)
|
48
|
-
* ("fld1" => "val1", "fld2" => /val2_regex/)
|
49
|
-
NOTE: single Solr document must satisfy all key value pairs
|
50
|
-
* ("fldname" => ["val1", /val2_regex/, "val3"])
|
51
|
-
NOTE: all of the Array values must be present for the fld in a single Solr document
|
52
|
-
should_not for Array implies NONE of the values should be present in a single document
|
53
|
-
|
54
|
-
More Ideas (TODO):
|
55
|
-
* include_title("val") (i.e. include_anyFieldName("val") )
|
56
|
-
|
57
|
-
==== Specifying Multiple Documents
|
58
|
-
===== Array
|
59
|
-
* by id strings: (["id1", "id2", "id3"])
|
60
|
-
* by hashes: ([{"title" => "green is best"}, {"title" => /blue/}, {"fld" => "val"}])
|
61
|
-
NOTE: you cannot do this: ([{"title" => ["Solr doc 1 title", "Solr doc 2 title"]} ]) to specify multiple documents
|
62
|
-
* by mix of id strings and hashes: ([{"title" => "green is best"}, "id3", {"author" => "steinbeck"}])
|
63
|
-
|
64
|
-
==== Full Examples
|
65
|
-
* rspec-solr_resp_hash.should include("fld1" => "val1")
|
66
|
-
* rspec-solr_resp_hash.should include("fld1" => /regex_for_val/)
|
67
|
-
* rspec-solr_resp_hash.should include("f1" => "v1", "f2" => ["val1", "val2", /regex_for_val/])
|
68
|
-
* rspec-solr_resp_hash.should include("idval")
|
69
|
-
* rspec-solr_resp_hash.should include(["id1", "id2", "id3"])
|
70
|
-
* rspec-solr_resp_hash.should include([{"title" => "title1"}, {"title" => "title2"}])
|
71
|
-
* rspec-solr_resp_hash.should include([{"title" => "title1"}, {"title" => "title2"}, "id8"])
|
72
|
-
|
73
|
-
== MATCHING SPECIFIC DOCUMENTS OCCURRING IN FIRST N RESULTS
|
74
|
-
|
75
|
-
NOTE: this is about the Solr documents returned in THIS response
|
76
|
-
|
77
|
-
=== Matchers
|
78
|
-
* include().as_first
|
79
|
-
* include().as_first.document
|
80
|
-
* include().in_first(n)
|
81
|
-
* include(Array).in_first(n).results
|
82
|
-
* include(Hash).in_each_of_first(n).documents
|
83
|
-
|
84
|
-
Note that the following are equivalent:
|
85
|
-
* include().blah.document
|
86
|
-
* include().blah.documents
|
87
|
-
* include().blah.result
|
88
|
-
* include().blah.results
|
89
|
-
|
90
|
-
TODO:
|
91
|
-
* include_at_least(3).of_these_documents().in_first(3).results
|
92
|
-
* start_with()
|
93
|
-
|
94
|
-
=== Usage
|
95
|
-
See above for information on how to specify specific documents
|
96
|
-
* rspec-solr_resp_hash.should include("111").as_first.document
|
97
|
-
* rspec-solr_resp_hash.should include(["111", "222"]).as_first.documents
|
98
|
-
* rspec-solr_resp_hash.should include([{"title" => "title1"}, {"title" => "title2"}]).in_first(3).results
|
99
|
-
* rspec-solr_resp_hash.should include("fld1" => "val1").in_first(3)
|
100
|
-
* rspec-solr_resp_hash.should include("title" => /cooking/).in_first(3).results
|
101
|
-
|
102
|
-
|
103
|
-
== MATCHING RELATIVE ORDER OF SPECIFIC DOCUMENTS
|
104
|
-
|
105
|
-
NOTE: this is about the Solr documents returned in THIS response
|
106
|
-
|
107
|
-
=== Matcher
|
108
|
-
* include().before()
|
109
|
-
NOTE: documents are specified the same way inside both sets of parens (see Usage for examples and see above re: specifying documents)
|
110
|
-
|
111
|
-
TODO: Potential Syntax:
|
112
|
-
* include().before_first_occurrence_of()
|
113
|
-
* include().within(3).of_document()
|
114
|
-
* subject.document(:title => 'vala').should come_before(subject.document(:title =>'valb'))
|
115
|
-
* subject.should have_result_field_ordered("title", "vala", "valb")
|
116
|
-
|
117
|
-
=== Usage
|
118
|
-
* rspec-solr_resp_hash.should include("111").before("222")
|
119
|
-
* rspec-solr_resp_hash.should include("fld"=>"val").before("fld"=>["val1", "val2", "val3"])
|
120
|
-
* rspec-solr_resp_hash.should include([{"title" => "title1"}, {"title" => "title2"}]).before("title" => "title3")
|
121
|
-
|
122
|
-
|
123
|
-
== COMPARING TOTAL RESULTS OF TWO RESPONSES
|
124
|
-
|
125
|
-
NOTE: this is about the TOTAL number of Solr documents that match ("numFound"), NOT solely the documents returned in THESE responses
|
126
|
-
|
127
|
-
=== Matchers
|
128
|
-
* have_more_results_than()
|
129
|
-
* have_fewer_results_than()
|
130
|
-
* have_the_same_number_of_results_as()
|
131
|
-
* have_more_documents_than()
|
132
|
-
* have_fewer_documents_than()
|
133
|
-
* have_the_same_number_of_documents_as()
|
134
|
-
|
135
|
-
=== Usage
|
136
|
-
* rspec-solr_resp_hash1.should have_more_results_than(rspec-solr_resp_hash2)
|
137
|
-
* rspec-solr_resp_hash1.should have_fewer_results_than(rspec-solr_resp_hash2)
|
138
|
-
* rspec-solr_resp_hash1.should have_the_same_number_of_results_as(rspec-solr_resp_hash2)
|
139
|
-
|
140
|
-
==== Alternate (allows more granularity)
|
141
|
-
* rspec-solr_resp_hash1.size.should > rspec-solr_resp_hash2.size
|
142
|
-
* rspec-solr_resp_hash1.size.should >= rspec-solr_resp_hash2.size
|
143
|
-
* rspec-solr_resp_hash1.size.should < rspec-solr_resp_hash2.size
|
144
|
-
* rspec-solr_resp_hash1.size.should <= rspec-solr_resp_hash2.size
|
145
|
-
* rspec-solr_resp_hash1.size.should == rspec-solr_resp_hash2.size
|
146
|
-
* rspec-solr_resp_hash1.size.should be_within(delta).of(rspec-solr_resp_hash2.size)
|
147
|
-
|
148
|
-
== MATCHING FACET VALUES IN RESPONSE
|
149
|
-
|
150
|
-
NOTE: this is about the facet counts returned in THIS response
|
151
|
-
|
152
|
-
=== Matchers
|
153
|
-
* have_facet_field()
|
154
|
-
* have_facet_field().with_value()
|
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/spec/support/matchers.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# This file shamelessly copied from rspec-expecations/spec/support/matchers.rb
|
2
|
-
RSpec::Matchers.define :include_method do |expected|
|
3
|
-
match do |actual|
|
4
|
-
actual.map { |m| m.to_s }.include?(expected.to_s)
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
module RSpec
|
9
|
-
module Matchers
|
10
|
-
def fail
|
11
|
-
raise_error(RSpec::Expectations::ExpectationNotMetError)
|
12
|
-
end
|
13
|
-
|
14
|
-
def fail_with(message)
|
15
|
-
raise_error(RSpec::Expectations::ExpectationNotMetError, message)
|
16
|
-
end
|
17
|
-
|
18
|
-
def fail_matching(message)
|
19
|
-
raise_error(RSpec::Expectations::ExpectationNotMetError, /#{Regexp.escape(message)}/)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|