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/lib/rspec-solr/version.rb
CHANGED
data/lib/tasks/ci.rake
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
desc
|
2
|
-
task :ci do
|
3
|
-
Rake::Task[
|
4
|
-
Rake::Task[
|
1
|
+
desc 'run continuous integration suite (tests, coverage, docs)'
|
2
|
+
task :ci do
|
3
|
+
Rake::Task['rspec'].invoke
|
4
|
+
Rake::Task['doc'].invoke
|
5
5
|
end
|
data/lib/tasks/doc.rake
CHANGED
@@ -3,19 +3,19 @@ require 'yard/rake/yardoc_task'
|
|
3
3
|
|
4
4
|
# Use yard to build docs
|
5
5
|
begin
|
6
|
-
project_root = File.expand_path(File.dirname(__FILE__) +
|
6
|
+
project_root = File.expand_path(File.dirname(__FILE__) + '/../..')
|
7
7
|
doc_dest_dir = File.join(project_root, 'doc')
|
8
8
|
|
9
9
|
YARD::Rake::YardocTask.new(:doc) do |yt|
|
10
10
|
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb'))
|
11
|
-
yt.options = ['--output-dir', doc_dest_dir,
|
12
|
-
'--readme', 'README.
|
13
|
-
'--title', 'RSpec-Solr Documentation',
|
14
|
-
'--files', 'MATCHERS.
|
11
|
+
yt.options = ['--output-dir', doc_dest_dir,
|
12
|
+
'--readme', 'README.md',
|
13
|
+
'--title', 'RSpec-Solr Documentation',
|
14
|
+
'--files', 'MATCHERS.md']
|
15
15
|
end
|
16
16
|
rescue LoadError
|
17
|
-
desc
|
17
|
+
desc 'Generate YARD Documentation'
|
18
18
|
task :doc do
|
19
|
-
abort
|
19
|
+
abort 'Please install the YARD gem to generate rdoc.'
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
data/lib/tasks/spec.rake
CHANGED
data/rspec-solr.gemspec
CHANGED
@@ -3,33 +3,33 @@
|
|
3
3
|
require File.expand_path('../lib/rspec-solr/version', __FILE__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.name =
|
6
|
+
gem.name = 'rspec-solr'
|
7
7
|
gem.version = RSpecSolr::VERSION
|
8
|
-
gem.authors = [
|
9
|
-
gem.email = [
|
10
|
-
gem.description =
|
11
|
-
gem.summary =
|
12
|
-
gem.homepage =
|
8
|
+
gem.authors = ['Naomi Dushay', 'Chris Beer']
|
9
|
+
gem.email = ['ndushay@stanford.edu', 'cabeer@stanford.edu']
|
10
|
+
gem.description = 'Provides RSpec custom matchers to be used with Solr response objects.'
|
11
|
+
gem.summary = 'RSpec custom matchers for Solr response objects'
|
12
|
+
gem.homepage = 'http://github.com/sul-dlss/rspec-solr'
|
13
13
|
|
14
|
-
gem.extra_rdoc_files = [
|
15
|
-
gem.files = `git ls-files`.split(
|
14
|
+
gem.extra_rdoc_files = ['LICENSE.txt', 'README.md', 'MATCHERS.md']
|
15
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
16
16
|
gem.test_files = gem.files.grep(%r{^spec/})
|
17
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
-
gem.require_path = [
|
19
|
-
|
20
|
-
gem.add_runtime_dependency
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
18
|
+
gem.require_path = ['lib']
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'rspec', '~> 3.0'
|
21
|
+
gem.add_runtime_dependency 'rspec-collection_matchers'
|
21
22
|
|
22
23
|
# Development dependencies
|
23
24
|
# Bundler will install these gems too if you've checked out rspec-solr source from git and run 'bundle install'
|
24
25
|
# It will not add these as dependencies if you require rspec-solr for other projects
|
25
|
-
gem.add_development_dependency
|
26
|
+
gem.add_development_dependency 'rake'
|
26
27
|
# docs
|
27
|
-
gem.add_development_dependency
|
28
|
-
gem.add_development_dependency
|
28
|
+
gem.add_development_dependency 'rdoc'
|
29
|
+
gem.add_development_dependency 'yard'
|
29
30
|
# test coverage for this gem
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
gem.add_development_dependency 'simplecov'
|
32
|
+
# continuous integration
|
33
|
+
gem.add_development_dependency 'travis-lint'
|
34
|
+
gem.add_development_dependency 'rubocop'
|
35
35
|
end
|
@@ -2,276 +2,264 @@ require 'spec_helper'
|
|
2
2
|
require 'rspec-solr'
|
3
3
|
|
4
4
|
describe RSpecSolr do
|
5
|
-
|
6
5
|
# fixtures below
|
7
6
|
|
8
|
-
context
|
9
|
-
it
|
10
|
-
@solr_resp_1_doc.
|
11
|
-
@solr_resp_3_docs.
|
12
|
-
@solr_resp_many_docs.
|
7
|
+
context 'should have_the_same_number_of_results_as()' do
|
8
|
+
it 'passes if both results have same total number of documents' do
|
9
|
+
expect(@solr_resp_1_doc).to have_the_same_number_of_results_as(@solr_resp_1_doc)
|
10
|
+
expect(@solr_resp_3_docs).to have_the_same_number_of_results_as(@solr_resp_3_docs)
|
11
|
+
expect(@solr_resp_many_docs).to have_the_same_number_of_results_as(@solr_resp_many_docs2)
|
13
12
|
end
|
14
|
-
it
|
15
|
-
@solr_resp_no_docs.
|
13
|
+
it 'passes if neither search matches any documents' do
|
14
|
+
expect(@solr_resp_no_docs).to have_the_same_number_of_results_as(@solr_resp_no_docs)
|
16
15
|
end
|
17
|
-
it
|
18
|
-
|
19
|
-
@solr_resp_not3_docs.
|
20
|
-
|
16
|
+
it 'fails if the first response has more total results' do
|
17
|
+
expect do
|
18
|
+
expect(@solr_resp_not3_docs).to have_the_same_number_of_results_as(@solr_resp_3_docs)
|
19
|
+
end.to raise_error.with_message a_string_including 'expected 8 documents in Solr response {'
|
21
20
|
end
|
22
|
-
it
|
23
|
-
|
24
|
-
@solr_resp_3_docs.
|
25
|
-
|
21
|
+
it 'fails if the first response has fewer total results' do
|
22
|
+
expect do
|
23
|
+
expect(@solr_resp_3_docs).to have_the_same_number_of_results_as(@solr_resp_not3_docs)
|
24
|
+
end.to raise_error.with_message a_string_including 'expected 3 documents in Solr response {'
|
26
25
|
end
|
27
|
-
it
|
28
|
-
|
29
|
-
@solr_resp_no_docs.
|
30
|
-
|
31
|
-
|
32
|
-
@solr_resp_3_docs.
|
33
|
-
|
26
|
+
it 'fails if only one response has results' do
|
27
|
+
expect do
|
28
|
+
expect(@solr_resp_no_docs).to have_the_same_number_of_results_as(@solr_resp_not3_docs)
|
29
|
+
end.to raise_error.with_message a_string_including 'expected 0 documents in Solr response {'
|
30
|
+
expect do
|
31
|
+
expect(@solr_resp_3_docs).to have_the_same_number_of_results_as(@solr_resp_no_docs)
|
32
|
+
end.to raise_error.with_message a_string_including 'expected 3 documents in Solr response {'
|
34
33
|
end
|
35
34
|
end # should have_the_same_number_of_results_as()
|
36
35
|
|
37
|
-
context
|
38
|
-
it
|
39
|
-
|
40
|
-
@solr_resp_1_doc.
|
41
|
-
|
42
|
-
|
43
|
-
@solr_resp_3_docs.
|
44
|
-
|
45
|
-
|
46
|
-
@solr_resp_many_docs.
|
47
|
-
|
36
|
+
context 'should_NOT have_the_same_number_of_results_as()' do
|
37
|
+
it 'fails if both results have same total number of documents' do
|
38
|
+
expect do
|
39
|
+
expect(@solr_resp_1_doc).not_to have_the_same_number_of_results_as(@solr_resp_1_doc)
|
40
|
+
end.to raise_error.with_message a_string_including 'expected (not 1) documents in Solr response {'
|
41
|
+
expect do
|
42
|
+
expect(@solr_resp_3_docs).not_to have_the_same_number_of_results_as(@solr_resp_3_docs)
|
43
|
+
end.to raise_error.with_message a_string_including 'expected (not 3) documents in Solr response {'
|
44
|
+
expect do
|
45
|
+
expect(@solr_resp_many_docs).not_to have_the_same_number_of_results_as(@solr_resp_many_docs2)
|
46
|
+
end.to raise_error.with_message a_string_including 'expected (not 1019) documents in Solr response {'
|
48
47
|
end
|
49
|
-
it
|
50
|
-
|
51
|
-
@solr_resp_no_docs.
|
52
|
-
|
48
|
+
it 'fails if neither search matches any documents' do
|
49
|
+
expect do
|
50
|
+
expect(@solr_resp_no_docs).not_to have_the_same_number_of_results_as(@solr_resp_no_docs)
|
51
|
+
end.to raise_error.with_message a_string_including 'expected (not 0) documents in Solr response {'
|
53
52
|
end
|
54
|
-
it
|
55
|
-
@solr_resp_not3_docs.
|
53
|
+
it 'passes if the first response has more total results' do
|
54
|
+
expect(@solr_resp_not3_docs).not_to have_the_same_number_of_results_as(@solr_resp_3_docs)
|
56
55
|
end
|
57
|
-
it
|
58
|
-
@solr_resp_3_docs.
|
56
|
+
it 'passes if the first response has fewer total results' do
|
57
|
+
expect(@solr_resp_3_docs).not_to have_the_same_number_of_results_as(@solr_resp_not3_docs)
|
59
58
|
end
|
60
|
-
it
|
61
|
-
@solr_resp_no_docs.
|
62
|
-
@solr_resp_3_docs.
|
59
|
+
it 'passes if only one response has results' do
|
60
|
+
expect(@solr_resp_no_docs).not_to have_the_same_number_of_results_as(@solr_resp_not3_docs)
|
61
|
+
expect(@solr_resp_3_docs).not_to have_the_same_number_of_results_as(@solr_resp_no_docs)
|
63
62
|
end
|
64
63
|
end # should_NOT have_the_same_number_of_results_as()
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@solr_resp_no_docs.
|
70
|
-
@solr_resp_no_docs.should have_fewer_results_than(@solr_resp_many_docs)
|
65
|
+
context 'should have_fewer_results_than()' do
|
66
|
+
it 'passes if first response has no results and second doc has results' do
|
67
|
+
expect(@solr_resp_no_docs).to have_fewer_results_than(@solr_resp_1_doc)
|
68
|
+
expect(@solr_resp_no_docs).to have_fewer_results_than(@solr_resp_many_docs)
|
71
69
|
end
|
72
|
-
it
|
73
|
-
@solr_resp_1_doc.
|
74
|
-
@solr_resp_3_docs.
|
75
|
-
@solr_resp_3_docs.
|
70
|
+
it 'passes if first response has a smaller number of total results' do
|
71
|
+
expect(@solr_resp_1_doc).to have_fewer_results_than(@solr_resp_3_docs)
|
72
|
+
expect(@solr_resp_3_docs).to have_fewer_results_than(@solr_resp_not3_docs)
|
73
|
+
expect(@solr_resp_3_docs).to have_fewer_results_than(@solr_resp_many_docs)
|
76
74
|
end
|
77
|
-
it
|
78
|
-
|
79
|
-
@solr_resp_3_docs.
|
80
|
-
|
81
|
-
|
82
|
-
@solr_resp_many_docs.
|
83
|
-
|
84
|
-
|
85
|
-
@solr_resp_no_docs.
|
86
|
-
|
75
|
+
it 'fails if responses have same number of total results' do
|
76
|
+
expect do
|
77
|
+
expect(@solr_resp_3_docs).to have_fewer_results_than(@solr_resp_3_docs)
|
78
|
+
end.to raise_error.with_message a_string_including 'expected more than 3 documents in Solr response {'
|
79
|
+
expect do
|
80
|
+
expect(@solr_resp_many_docs).to have_fewer_results_than(@solr_resp_many_docs2)
|
81
|
+
end.to raise_error.with_message a_string_including 'expected more than 1019 documents in Solr response {'
|
82
|
+
expect do
|
83
|
+
expect(@solr_resp_no_docs).to have_fewer_results_than(@solr_resp_no_docs)
|
84
|
+
end.to raise_error.with_message a_string_including 'expected more than 0 documents in Solr response {'
|
87
85
|
end
|
88
|
-
it
|
89
|
-
|
90
|
-
@solr_resp_3_docs.
|
91
|
-
|
92
|
-
|
93
|
-
@solr_resp_not3_docs.
|
94
|
-
|
95
|
-
|
96
|
-
@solr_resp_not3_docs.
|
97
|
-
|
86
|
+
it 'fails if first response has more total results' do
|
87
|
+
expect do
|
88
|
+
expect(@solr_resp_3_docs).to have_fewer_results_than(@solr_resp_1_doc)
|
89
|
+
end.to raise_error.with_message a_string_including 'expected more than 3 documents in Solr response {'
|
90
|
+
expect do
|
91
|
+
expect(@solr_resp_not3_docs).to have_fewer_results_than(@solr_resp_3_docs)
|
92
|
+
end.to raise_error.with_message a_string_including 'expected more than 8 documents in Solr response {'
|
93
|
+
expect do
|
94
|
+
expect(@solr_resp_not3_docs).to have_fewer_results_than(@solr_resp_no_docs)
|
95
|
+
end.to raise_error.with_message a_string_including 'expected more than 8 documents in Solr response {'
|
98
96
|
end
|
99
97
|
end # should have_fewer_results_than()
|
100
98
|
|
101
|
-
context
|
102
|
-
it
|
103
|
-
|
104
|
-
@solr_resp_no_docs.
|
105
|
-
|
106
|
-
|
107
|
-
@solr_resp_no_docs.
|
108
|
-
|
99
|
+
context 'should_NOT have_fewer_results_than()' do
|
100
|
+
it 'fails if first response has no results and second doc has results' do
|
101
|
+
expect do
|
102
|
+
expect(@solr_resp_no_docs).not_to have_fewer_results_than(@solr_resp_1_doc)
|
103
|
+
end.to raise_error.with_message a_string_including 'expected 0 or fewer documents in Solr response {'
|
104
|
+
expect do
|
105
|
+
expect(@solr_resp_no_docs).not_to have_fewer_results_than(@solr_resp_many_docs)
|
106
|
+
end.to raise_error.with_message a_string_including 'expected 0 or fewer documents in Solr response {'
|
109
107
|
end
|
110
|
-
it
|
111
|
-
|
112
|
-
@solr_resp_1_doc.
|
113
|
-
|
114
|
-
|
115
|
-
@solr_resp_3_docs.
|
116
|
-
|
117
|
-
|
118
|
-
@solr_resp_3_docs.
|
119
|
-
|
108
|
+
it 'fails if first response has a smaller number of total results' do
|
109
|
+
expect do
|
110
|
+
expect(@solr_resp_1_doc).not_to have_fewer_results_than(@solr_resp_3_docs)
|
111
|
+
end.to raise_error.with_message a_string_including 'expected 1 or fewer documents in Solr response {'
|
112
|
+
expect do
|
113
|
+
expect(@solr_resp_3_docs).not_to have_fewer_results_than(@solr_resp_not3_docs)
|
114
|
+
end.to raise_error.with_message a_string_including 'expected 3 or fewer documents in Solr response {'
|
115
|
+
expect do
|
116
|
+
expect(@solr_resp_3_docs).not_to have_fewer_results_than(@solr_resp_many_docs)
|
117
|
+
end.to raise_error.with_message a_string_including 'expected 3 or fewer documents in Solr response {'
|
120
118
|
end
|
121
|
-
it
|
122
|
-
@solr_resp_3_docs.
|
123
|
-
@solr_resp_many_docs.
|
124
|
-
@solr_resp_no_docs.
|
119
|
+
it 'passes if responses have same number of total results' do
|
120
|
+
expect(@solr_resp_3_docs).not_to have_fewer_results_than(@solr_resp_3_docs)
|
121
|
+
expect(@solr_resp_many_docs).not_to have_fewer_results_than(@solr_resp_many_docs2)
|
122
|
+
expect(@solr_resp_no_docs).not_to have_fewer_results_than(@solr_resp_no_docs)
|
125
123
|
end
|
126
|
-
it
|
127
|
-
@solr_resp_3_docs.
|
128
|
-
@solr_resp_not3_docs.
|
129
|
-
@solr_resp_not3_docs.
|
124
|
+
it 'passes if first response has more total results' do
|
125
|
+
expect(@solr_resp_3_docs).not_to have_fewer_results_than(@solr_resp_1_doc)
|
126
|
+
expect(@solr_resp_not3_docs).not_to have_fewer_results_than(@solr_resp_3_docs)
|
127
|
+
expect(@solr_resp_not3_docs).not_to have_fewer_results_than(@solr_resp_no_docs)
|
130
128
|
end
|
131
129
|
end # should_NOT have_fewer_results_than()
|
132
130
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@
|
137
|
-
@solr_resp_many_docs.should have_more_results_than(@solr_resp_no_docs)
|
131
|
+
context 'should have_more_results_than()' do
|
132
|
+
it 'passes if first response has results and second response does not' do
|
133
|
+
expect(@solr_resp_1_doc).to have_more_results_than(@solr_resp_no_docs)
|
134
|
+
expect(@solr_resp_many_docs).to have_more_results_than(@solr_resp_no_docs)
|
138
135
|
end
|
139
|
-
it
|
140
|
-
@solr_resp_3_docs.
|
141
|
-
@solr_resp_not3_docs.
|
142
|
-
@solr_resp_many_docs.
|
136
|
+
it 'passes if first response has a larger number of total results' do
|
137
|
+
expect(@solr_resp_3_docs).to have_more_results_than(@solr_resp_1_doc)
|
138
|
+
expect(@solr_resp_not3_docs).to have_more_results_than(@solr_resp_3_docs)
|
139
|
+
expect(@solr_resp_many_docs).to have_more_results_than(@solr_resp_not3_docs)
|
143
140
|
end
|
144
|
-
it
|
145
|
-
|
146
|
-
@solr_resp_3_docs.
|
147
|
-
|
148
|
-
|
149
|
-
@solr_resp_many_docs.
|
150
|
-
|
151
|
-
|
152
|
-
@solr_resp_no_docs.
|
153
|
-
|
141
|
+
it 'fails if responses have same number of total results' do
|
142
|
+
expect do
|
143
|
+
expect(@solr_resp_3_docs).to have_more_results_than(@solr_resp_3_docs)
|
144
|
+
end.to raise_error.with_message a_string_including 'expected fewer than 3 documents in Solr response {'
|
145
|
+
expect do
|
146
|
+
expect(@solr_resp_many_docs).to have_more_results_than(@solr_resp_many_docs2)
|
147
|
+
end.to raise_error.with_message a_string_including 'expected fewer than 1019 documents in Solr response {'
|
148
|
+
expect do
|
149
|
+
expect(@solr_resp_no_docs).to have_more_results_than(@solr_resp_no_docs)
|
150
|
+
end.to raise_error.with_message a_string_including 'expected fewer than 0 documents in Solr response {'
|
154
151
|
end
|
155
|
-
it
|
156
|
-
|
157
|
-
@solr_resp_1_doc.
|
158
|
-
|
159
|
-
|
160
|
-
@solr_resp_3_docs.
|
161
|
-
|
162
|
-
|
163
|
-
@solr_resp_3_docs.
|
164
|
-
|
152
|
+
it 'fails if first response has fewer total results' do
|
153
|
+
expect do
|
154
|
+
expect(@solr_resp_1_doc).to have_more_results_than(@solr_resp_3_docs)
|
155
|
+
end.to raise_error.with_message a_string_including 'expected fewer than 1 documents in Solr response {'
|
156
|
+
expect do
|
157
|
+
expect(@solr_resp_3_docs).to have_more_results_than(@solr_resp_not3_docs)
|
158
|
+
end.to raise_error.with_message a_string_including 'expected fewer than 3 documents in Solr response {'
|
159
|
+
expect do
|
160
|
+
expect(@solr_resp_3_docs).to have_more_results_than(@solr_resp_many_docs)
|
161
|
+
end.to raise_error.with_message a_string_including 'expected fewer than 3 documents in Solr response {'
|
165
162
|
end
|
166
163
|
end # should have_more_results_than()
|
167
164
|
|
168
|
-
context
|
169
|
-
it
|
170
|
-
|
171
|
-
@solr_resp_1_doc.
|
172
|
-
|
173
|
-
|
174
|
-
@solr_resp_many_docs.
|
175
|
-
|
165
|
+
context 'should_NOT have_more_results_than()' do
|
166
|
+
it 'fails if first response has results and second response does not' do
|
167
|
+
expect do
|
168
|
+
expect(@solr_resp_1_doc).not_to have_more_results_than(@solr_resp_no_docs)
|
169
|
+
end.to raise_error.with_message a_string_including 'expected 1 or more documents in Solr response {'
|
170
|
+
expect do
|
171
|
+
expect(@solr_resp_many_docs).not_to have_more_results_than(@solr_resp_no_docs)
|
172
|
+
end.to raise_error.with_message a_string_including 'expected 1019 or more documents in Solr response {'
|
176
173
|
end
|
177
|
-
it
|
178
|
-
|
179
|
-
@solr_resp_3_docs.
|
180
|
-
|
181
|
-
|
182
|
-
@solr_resp_not3_docs.
|
183
|
-
|
184
|
-
|
185
|
-
@solr_resp_many_docs.
|
186
|
-
|
174
|
+
it 'fails if first response has a larger number of total results' do
|
175
|
+
expect do
|
176
|
+
expect(@solr_resp_3_docs).not_to have_more_results_than(@solr_resp_1_doc)
|
177
|
+
end.to raise_error.with_message a_string_including 'expected 3 or more documents in Solr response {'
|
178
|
+
expect do
|
179
|
+
expect(@solr_resp_not3_docs).not_to have_more_results_than(@solr_resp_3_docs)
|
180
|
+
end.to raise_error.with_message a_string_including 'expected 8 or more documents in Solr response {'
|
181
|
+
expect do
|
182
|
+
expect(@solr_resp_many_docs).not_to have_more_results_than(@solr_resp_not3_docs)
|
183
|
+
end.to raise_error.with_message a_string_including 'expected 1019 or more documents in Solr response {'
|
187
184
|
end
|
188
|
-
it
|
189
|
-
@solr_resp_3_docs.
|
190
|
-
@solr_resp_many_docs.
|
191
|
-
@solr_resp_no_docs.
|
185
|
+
it 'passes if responses have same number of total results' do
|
186
|
+
expect(@solr_resp_3_docs).not_to have_more_results_than(@solr_resp_3_docs)
|
187
|
+
expect(@solr_resp_many_docs).not_to have_more_results_than(@solr_resp_many_docs2)
|
188
|
+
expect(@solr_resp_no_docs).not_to have_more_results_than(@solr_resp_no_docs)
|
192
189
|
end
|
193
|
-
it
|
194
|
-
@solr_resp_1_doc.
|
195
|
-
@solr_resp_3_docs.
|
196
|
-
@solr_resp_3_docs.
|
190
|
+
it 'passes if first response has fewer total results' do
|
191
|
+
expect(@solr_resp_1_doc).not_to have_more_results_than(@solr_resp_3_docs)
|
192
|
+
expect(@solr_resp_3_docs).not_to have_more_results_than(@solr_resp_not3_docs)
|
193
|
+
expect(@solr_resp_3_docs).not_to have_more_results_than(@solr_resp_many_docs)
|
197
194
|
end
|
198
195
|
end # should_NOT have_more_results_than()
|
199
196
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
@
|
204
|
-
@solr_resp_not3_docs.should_not have_the_same_number_of_documents_as(@solr_resp_3_docs)
|
197
|
+
context 'the word documents should be interchangeable with results' do
|
198
|
+
it 'have_the_same_number_of_documents_as' do
|
199
|
+
expect(@solr_resp_1_doc).to have_the_same_number_of_documents_as(@solr_resp_1_doc)
|
200
|
+
expect(@solr_resp_not3_docs).not_to have_the_same_number_of_documents_as(@solr_resp_3_docs)
|
205
201
|
end
|
206
|
-
it
|
207
|
-
@solr_resp_3_docs.
|
208
|
-
@solr_resp_many_docs.
|
202
|
+
it 'have_fewer_results_than' do
|
203
|
+
expect(@solr_resp_3_docs).to have_fewer_results_than(@solr_resp_not3_docs)
|
204
|
+
expect(@solr_resp_many_docs).not_to have_fewer_results_than(@solr_resp_many_docs2)
|
209
205
|
end
|
210
|
-
it
|
211
|
-
@solr_resp_not3_docs.
|
212
|
-
@solr_resp_1_doc.
|
206
|
+
it 'have_more_results_than' do
|
207
|
+
expect(@solr_resp_not3_docs).to have_more_results_than(@solr_resp_3_docs)
|
208
|
+
expect(@solr_resp_1_doc).not_to have_more_documents_than(@solr_resp_3_docs)
|
213
209
|
end
|
214
210
|
end
|
215
211
|
|
216
|
-
|
217
212
|
before(:all) do
|
218
|
-
@solr_resp_1_doc = RSpecSolr::SolrResponseHash.new(
|
219
|
-
{
|
220
|
-
|
221
|
-
|
222
|
-
}
|
223
|
-
})
|
213
|
+
@solr_resp_1_doc = RSpecSolr::SolrResponseHash.new('response' =>
|
214
|
+
{ 'numFound' => 1,
|
215
|
+
'start' => 0,
|
216
|
+
'docs' => [{ 'id' => '111' }]
|
217
|
+
})
|
224
218
|
|
225
|
-
@solr_resp_3_docs = RSpecSolr::SolrResponseHash.new(
|
226
|
-
{
|
227
|
-
|
228
|
-
|
229
|
-
[
|
230
|
-
|
231
|
-
|
219
|
+
@solr_resp_3_docs = RSpecSolr::SolrResponseHash.new('response' =>
|
220
|
+
{ 'numFound' => 3,
|
221
|
+
'start' => 0,
|
222
|
+
'docs' =>
|
223
|
+
[{ 'id' => '111' },
|
224
|
+
{ 'id' => '222' },
|
225
|
+
{ 'id' => '333' }
|
232
226
|
]
|
233
|
-
}
|
234
|
-
})
|
227
|
+
})
|
235
228
|
|
236
|
-
@solr_resp_not3_docs = RSpecSolr::SolrResponseHash.new(
|
237
|
-
{
|
238
|
-
|
239
|
-
|
240
|
-
[
|
241
|
-
|
242
|
-
|
229
|
+
@solr_resp_not3_docs = RSpecSolr::SolrResponseHash.new('response' =>
|
230
|
+
{ 'numFound' => 8,
|
231
|
+
'start' => 0,
|
232
|
+
'docs' =>
|
233
|
+
[{ 'id' => '111' },
|
234
|
+
{ 'id' => '222' },
|
235
|
+
{ 'id' => '333' }
|
243
236
|
]
|
244
|
-
}
|
245
|
-
})
|
237
|
+
})
|
246
238
|
|
247
|
-
@solr_resp_many_docs = RSpecSolr::SolrResponseHash.new(
|
248
|
-
{
|
249
|
-
|
250
|
-
|
251
|
-
[
|
252
|
-
|
253
|
-
|
239
|
+
@solr_resp_many_docs = RSpecSolr::SolrResponseHash.new('response' =>
|
240
|
+
{ 'numFound' => 1019,
|
241
|
+
'start' => 0,
|
242
|
+
'docs' =>
|
243
|
+
[{ 'id' => '111' },
|
244
|
+
{ 'id' => '222' },
|
245
|
+
{ 'id' => '333' }
|
254
246
|
]
|
255
|
-
}
|
256
|
-
})
|
247
|
+
})
|
257
248
|
|
258
|
-
@solr_resp_many_docs2 = RSpecSolr::SolrResponseHash.new(
|
259
|
-
{
|
260
|
-
|
261
|
-
|
262
|
-
[
|
263
|
-
|
264
|
-
|
249
|
+
@solr_resp_many_docs2 = RSpecSolr::SolrResponseHash.new('response' =>
|
250
|
+
{ 'numFound' => 1019,
|
251
|
+
'start' => 10,
|
252
|
+
'docs' =>
|
253
|
+
[{ 'id' => '777' },
|
254
|
+
{ 'id' => '888' },
|
255
|
+
{ 'id' => '999' }
|
265
256
|
]
|
266
|
-
}
|
267
|
-
})
|
257
|
+
})
|
268
258
|
|
269
|
-
@solr_resp_no_docs = RSpecSolr::SolrResponseHash.new(
|
270
|
-
{
|
271
|
-
|
272
|
-
|
273
|
-
}
|
274
|
-
})
|
259
|
+
@solr_resp_no_docs = RSpecSolr::SolrResponseHash.new('response' =>
|
260
|
+
{ 'numFound' => 0,
|
261
|
+
'start' => 0,
|
262
|
+
'docs' => []
|
263
|
+
})
|
275
264
|
end
|
276
|
-
|
277
|
-
end
|
265
|
+
end
|