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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29844b0eff6a43c4cdcdd5362f62415149f88c08
4
- data.tar.gz: 484e4610bd1998ba05a32df00b501fed762bb1da
3
+ metadata.gz: 614534dc732f46bfc1fe137e447bec23eb04e480
4
+ data.tar.gz: 69fed90ebd9a576ebc14e52493a90e8d5c8ea8d2
5
5
  SHA512:
6
- metadata.gz: 8d6667795c37700d04732dc58adf51c9694d6076bead960f3cff38781084bd978bd56ef33b673ee4d26c93cc4c36fa6ca34a1599c3ffeceb481388ef37df8024
7
- data.tar.gz: 5d293800c943c18e7dfe85629fe0d45f4f37e62b0ebb923aa88a6ec3eb8ec4fb769a24260c8b4500933f19a82a3c4770686aa9f45264336275d50b71f98330f2
6
+ metadata.gz: b75ea440dcd94fdc5ff553af14dec0e56373a141aeb806abd9dec92d76655590f67bf744577e897471d50126bcb372ba07915a8985700d60552a49d66de882a4
7
+ data.tar.gz: 827e79d09922c16d08518a46c50d5dcf087be3d8826379187a89c6d40190c3db202f963774b52631ded7e4b9753ff617b3817e808593c7003ae67b1e462ec12a
@@ -0,0 +1,53 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-06-26 14:31:43 -0700 using RuboCop version 0.32.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 4
9
+ Metrics/AbcSize:
10
+ Max: 26
11
+
12
+ # Offense count: 2
13
+ # Configuration parameters: CountComments.
14
+ Metrics/ClassLength:
15
+ Max: 110
16
+
17
+ # Offense count: 4
18
+ Metrics/CyclomaticComplexity:
19
+ Max: 13
20
+
21
+ # Offense count: 409
22
+ # Configuration parameters: AllowURI, URISchemes.
23
+ Metrics/LineLength:
24
+ Max: 211
25
+
26
+ # Offense count: 11
27
+ # Configuration parameters: CountComments.
28
+ Metrics/MethodLength:
29
+ Max: 43
30
+
31
+ # Offense count: 4
32
+ Metrics/PerceivedComplexity:
33
+ Max: 16
34
+
35
+ # Offense count: 4
36
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
37
+ Style/ClassAndModuleChildren:
38
+ Enabled: false
39
+
40
+ # Offense count: 3
41
+ Style/Documentation:
42
+ Enabled: false
43
+
44
+ # Offense count: 1
45
+ # Configuration parameters: Exclude.
46
+ Style/FileName:
47
+ Enabled: false
48
+
49
+ # Offense count: 3
50
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist.
51
+ Style/PredicateName:
52
+ Enabled: false
53
+
@@ -1,8 +1,6 @@
1
1
  language: ruby
2
- script: rake rspec
3
2
  rvm:
4
- - 2.1.0
5
- - 2.0.0
3
+ - 2.2.2
6
4
  - 1.9.3
7
5
  - jruby-19mode
8
6
  notifications:
data/.yardopts CHANGED
@@ -1,3 +1,3 @@
1
1
  --title 'RSpecSolr Documentation'
2
2
  lib/**/*.rb -
3
- README.rdoc MATCHERS.rdoc LICENSE.txt
3
+ README.md MATCHERS.md LICENSE.txt
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # See rspec-solr.gemspec for this gem's dependencies
4
4
  gemspec
5
+
6
+ gem 'rspec', '~> 3.3'
@@ -0,0 +1,168 @@
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
+ * `expect(rspec-solr_resp_hash).to have_documents`
14
+ * `expect(rspec-solr_resp_hash).not_to 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
+ * `expect(rspec-solr_resp_hash).to include("fld1" => "val1")`
66
+ * `expect(rspec-solr_resp_hash).to include("fld1" => /regex_for_val/)`
67
+ * `expect(rspec-solr_resp_hash).to include("f1" => "v1", "f2" => ["val1", "val2", /regex_for_val/])`
68
+ * `expect(rspec-solr_resp_hash).to include("idval")`
69
+ * `expect(rspec-solr_resp_hash).to include(["id1", "id2", "id3"])`
70
+ * `expect(rspec-solr_resp_hash).to include([{"title" => "title1"}, {"title" => "title2"}])`
71
+ * `expect(rspec-solr_resp_hash).to 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
+ * `expect(rspec-solr_resp_hash).to include("111").as_first.document`
97
+ * `expect(rspec-solr_resp_hash).to include(["111", "222"]).as_first.documents`
98
+ * `expect(rspec-solr_resp_hash).to include([{"title" => "title1"}, {"title" => "title2"}]).in_first(3).results`
99
+ * `expect(rspec-solr_resp_hash).to include("fld1" => "val1").in_first(3)`
100
+ * `expect(rspec-solr_resp_hash).to include("title" => /cooking/).in_first(3).results`
101
+
102
+ ## MATCHING RELATIVE ORDER OF SPECIFIC DOCUMENTS
103
+
104
+ NOTE: this is about the Solr documents returned in THIS response
105
+
106
+ ### Matcher
107
+ * `include().before()`
108
+ NOTE: documents are specified the same way inside both sets of parens (see Usage for examples and see above re: specifying documents)
109
+
110
+ TODO: Potential Syntax:
111
+ * `include().before_first_occurrence_of()`
112
+ * `include().within(3).of_document()`
113
+ * `expect(subject.document(:title => 'vala')).to come_before(subject.document(:title =>'valb'))`
114
+ * `expect(subject).to have_result_field_ordered("title", "vala", "valb") `
115
+
116
+ ### Usage
117
+ * `expect(rspec-solr_resp_hash).to include("111").before("222")`
118
+ * `expect(rspec-solr_resp_hash).to include("fld"=>"val").before("fld"=>["val1", "val2", "val3"])`
119
+ * `expect(rspec-solr_resp_hash).to include([{"title" => "title1"}, {"title" => "title2"}]).before("title" => "title3")`
120
+
121
+
122
+ ## COMPARING TOTAL RESULTS OF TWO RESPONSES
123
+
124
+ NOTE: this is about the TOTAL number of Solr documents that match ("numFound"), NOT solely the documents returned in THESE responses
125
+
126
+ ### Matchers
127
+ * `have_more_results_than()`
128
+ * `have_fewer_results_than()`
129
+ * `have_the_same_number_of_results_as()`
130
+ * `have_more_documents_than()`
131
+ * `have_fewer_documents_than()`
132
+ * `have_the_same_number_of_documents_as()`
133
+
134
+ ### Usage
135
+ * `expect(rspec-solr_resp_hash1).to have_more_results_than(rspec-solr_resp_hash2)`
136
+ * `expect(rspec-solr_resp_hash1).to have_fewer_results_than(rspec-solr_resp_hash2)`
137
+ * `expect(rspec-solr_resp_hash1).to have_the_same_number_of_results_as(rspec-solr_resp_hash2)`
138
+
139
+ #### Alternate (allows more granularity)
140
+ * `expect(rspec-solr_resp_hash1.size).to > rspec-solr_resp_hash2.size`
141
+ * `expect(rspec-solr_resp_hash1.size).to >= rspec-solr_resp_hash2.size`
142
+ * `expect(rspec-solr_resp_hash1.size).to < rspec-solr_resp_hash2.size`
143
+ * `expect(rspec-solr_resp_hash1.size).to <= rspec-solr_resp_hash2.size`
144
+ * `expect(rspec-solr_resp_hash1.size).to == rspec-solr_resp_hash2.size`
145
+ * `expect(rspec-solr_resp_hash1.size).to be_within(delta).of(rspec-solr_resp_hash2.size)`
146
+
147
+ ## MATCHING FACET VALUES IN RESPONSE
148
+
149
+ NOTE: this is about the facet counts returned in THIS response
150
+
151
+ ### Matchers
152
+ * `have_facet_field()`
153
+ * `have_facet_field().with_value()`
154
+
155
+ ### Usage
156
+ * `expect(rspec-solr_resp_hash).to have_facet_field("author")`
157
+ * `expect(rspec-solr_resp_hash).to have_facet_field("author").with_value("Steinbeck, John")`
158
+
159
+ ### TODO:
160
+ * facets with arrarr and without (Solr option to get better facet formatting)
161
+ * `have_facet_field().with_value().with_count()`
162
+ * more ideas
163
+ * `facet(:format => "Book")`
164
+ * `facets(:format => ["Image", "Map"])`
165
+ * `include_facet().before_facet()`
166
+ * `include_facets().before_facet()`
167
+ * `include_facet().before_facets()`
168
+ * `include_facets().before_facets()`
@@ -1,10 +1,12 @@
1
- = RSpec Solr
1
+ [![Build Status](https://travis-ci.org/sul-dlss/rspec-solr.svg?branch=master)](https://travis-ci.org/sul-dlss/rspec-solr)
2
+ [![Coverage Status](https://coveralls.io/repos/sul-dlss/rspec-solr/badge.svg)](https://coveralls.io/r/sul-dlss/rspec-solr)
3
+ [![Dependency Status](https://gemnasium.com/sul-dlss/rspec-solr.svg)](https://gemnasium.com/sul-dlss/rspec-solr)
2
4
 
3
- {<img src="https://secure.travis-ci.org/sul-dlss/rspec-solr.png?branch=master" alt="Build Status" />}[http://travis-ci.org/sul-dlss/rspec-solr] {<img src="https://gemnasium.com/sul-dlss/rspec-solr.png" alt="Dependency Status" />}[https://gemnasium.com/sul-dlss/rspec-solr]
5
+ # RSpec Solr
4
6
 
5
7
  A Gem to provide RSpec custom matchers to be used with Solr response objects.
6
8
 
7
- == Installation
9
+ ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
10
12
 
@@ -18,12 +20,13 @@ Or install it yourself as:
18
20
 
19
21
  $ gem install rspec-solr
20
22
 
21
- == Usage
23
+ ## Usage
22
24
 
23
- See MATCHERS.rdoc for syntax of supported expectations.
25
+ See `MATCHERS.md` for syntax of supported expectations.
24
26
 
25
- === Examples:
27
+ ### Examples:
26
28
 
29
+ ```ruby
27
30
  it "q of 'Buddhism' should get 8,500-10,500 results" do
28
31
  resp = solr_resp_doc_ids_only({'q'=>'Buddhism'})
29
32
  resp.should have_at_least(8500).documents
@@ -45,50 +48,54 @@ See MATCHERS.rdoc for syntax of supported expectations.
45
48
  resp.should have_at_least(240).documents
46
49
  resp.should have_the_same_number_of_results_as(solr_resp_doc_ids_only({'q'=>'三国志'}))
47
50
  end
51
+ ```
48
52
 
49
- === How Do I Do That?
53
+ ### How Do I Do That?
50
54
 
51
55
  Essentially, you write a bunch of specs that
52
56
  * send a request to your Solr index
53
- * wrap the Solr Ruby response into the RSpecSolr::SolrResponseHash (blah = RSpecSolr::SolrResponseHash.new(orig_resp))
54
- * utilize the matchers (blah.should have_document("222")) -- see MATCHERS.rdoc
57
+ * wrap the Solr Ruby response into the `RSpecSolr::SolrResponseHash` (`blah = RSpecSolr::SolrResponseHash.new(orig_resp)``)
58
+ * utilize the matchers (`expect(blah).to have_document("222")``) -- see `MATCHERS.md`
55
59
 
56
60
  There is an exemplar project utilizing rspec-solr at https://github.com/sul-dlss/sw_index_tests.
57
61
 
58
62
  Besides the specs themselves, it has essentially 4 files to smooth the way.
59
63
 
60
- ==== 1. Gemfile
64
+ #### 1. Gemfile
61
65
  Indicate the required gems for bundler
62
66
 
63
- source :rubygems
64
-
65
- gem 'RedCloth' # for textile formatting used in Readme
66
- gem 'rake'
67
+ ```ruby
67
68
  gem 'rsolr' # for sending requests to and getting responses from solr
68
69
  gem 'rspec-solr' # for rspec assertions against solr response object
70
+ ```
69
71
 
70
- ==== 2. Rakefile
72
+ #### 2. Rakefile
71
73
  Make it easy to run various groups of specs from the command line
72
74
 
75
+ ```ruby
73
76
  require 'rspec/core/rake_task'
74
77
 
75
78
  desc "run specs expected to pass"
76
79
  RSpec::Core::RakeTask.new(:rspec) do |spec|
77
80
  spec.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
78
81
  end
82
+ ```
79
83
 
80
- ==== 3. config/solr.yml
84
+ #### 3. config/solr.yml
81
85
  Your Solr base url goes here
82
86
 
87
+ ```yaml
83
88
  test:
84
89
  :url: http://your_solr_baseurl
85
90
 
86
91
  dev:
87
92
  :url: http://your_solr_baseurl
93
+ ```
88
94
 
89
- ==== 4. spec/spec_helper.rb
95
+ #### 4. spec/spec_helper.rb
90
96
  Do a one time setup of Solr connection, and methods to make it easier to make desired Solr requests
91
97
 
98
+ ```ruby
92
99
  require "yaml"
93
100
  require 'rsolr'
94
101
 
@@ -110,10 +117,12 @@ Do a one time setup of Solr connection, and methods to make it easier to make de
110
117
  def solr_response(solr_params, req_handler='select')
111
118
  RSpecSolr::SolrResponseHash.new(@@solr.send_and_receive(req_handler, {:method => :get, :params => solr_params}))
112
119
  end
120
+ ```
113
121
 
114
- ===== 4a. a little more magic
122
+ #### 4a. a little more magic
115
123
  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
124
 
125
+ ```ruby
117
126
  # send a GET request to the default Solr request handler with the indicated Solr parameters
118
127
  # @param solr_params [Hash] the key/value pairs to be sent to Solr as HTTP parameters, in addition to
119
128
  # those to get only id fields and no facets in the response
@@ -128,19 +137,15 @@ You might want to add code such as that below to your spec_helper - it can help
128
137
  def doc_ids_only
129
138
  {'fl'=>'id', 'facet'=>'false'}
130
139
  end
131
-
132
-
133
- == Ruby Version Compatibility
134
-
135
- This should work with various rubies 1.8.7, but currently some tests expected ordered hashes (though the code itself doesn't require them - just THIS gem's TEST code).
140
+ ```
136
141
 
137
- == Contribute
142
+ ## Contribute
138
143
 
139
144
  I'm currently envisioning helper methods shared somehow - either on the github wikis, or in this gem as exemplars, or in a separate gem, or ...
140
145
 
141
146
  Please share yours!
142
147
 
143
- == Contributing
148
+ ## Contributing
144
149
 
145
150
  1. Fork it
146
151
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -148,7 +153,7 @@ Please share yours!
148
153
  4. Push to the branch (`git push origin my-new-feature`)
149
154
  5. Create new Pull Request
150
155
 
151
- == Releases
156
+ ## Releases
152
157
  - <b>1.0.1</b> fix spec failing in travis due to diff error message in later rspec version
153
158
  - <b>1.0.0</b> declare victory and make 0.2.0 into 1.0.0
154
159
  - <b>0.2.0</b> add facet support have_facet_field(fld_name).with_value(fld_value)
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/setup'
3
- require "bundler/gem_tasks"
3
+ require 'bundler/gem_tasks'
4
4
 
5
5
  require 'rake'
6
6
  require 'bundler'
@@ -9,11 +9,11 @@ begin
9
9
  Bundler.setup(:default, :development)
10
10
  rescue Bundler::BundlerError => e
11
11
  $stderr.puts e.message
12
- $stderr.puts "Run `bundle install` to install missing gems"
12
+ $stderr.puts 'Run `bundle install` to install missing gems'
13
13
  exit e.status_code
14
14
  end
15
15
 
16
16
  Dir.glob('lib/tasks/*.rake').each { |r| import r }
17
17
 
18
- task :default => :ci
19
- task :spec => :rspec
18
+ task default: :ci
19
+ task spec: :rspec
@@ -1,9 +1,8 @@
1
- require "rspec-solr/solr_response_hash"
2
- require "rspec-solr/compare_num_docs_matcher"
3
- require "rspec-solr/have_documents_matcher"
4
- require "rspec-solr/have_facet_field_matcher"
5
- require "rspec-solr/include_documents_matcher"
1
+ require 'rspec-solr/solr_response_hash'
2
+ require 'rspec-solr/compare_num_docs_matcher'
3
+ require 'rspec-solr/have_documents_matcher'
4
+ require 'rspec-solr/have_facet_field_matcher'
5
+ require 'rspec-solr/include_documents_matcher'
6
6
 
7
7
  module RSpecSolr::Matchers
8
-
9
- end
8
+ end
@@ -1,109 +1,92 @@
1
1
  # Custom RSpec Matchers for Solr responses
2
2
  module RSpecSolr::Matchers
3
-
4
- # Determine if the receiver has the same number of Solr docs as the expected
5
- # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
6
- def have_the_same_number_of_results_as
7
- # Placeholder method for documentation purposes;
8
- # the actual method is defined using RSpec's matcher DSL
9
- end
10
-
11
- # Determine if the receiver has fewer Solr docs than the expected
12
- # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
13
- def have_fewer_results_than
14
- # Placeholder method for documentation purposes;
15
- # the actual method is defined using RSpec's matcher DSL
16
- end
17
-
18
- # Determine if the receiver has more Solr docs than the expected
19
- # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
20
- def have_more_results_than
21
- # Placeholder method for documentation purposes;
22
- # the actual method is defined using RSpec's matcher DSL
23
- end
24
-
25
- # this is the lambda used to determine if the receiver (a Solr response object) has the same number of total documents
3
+ # this is the lambda used to determine if the receiver (a Solr response object) has the same number of total documents
26
4
  # as the expected RSpecSolr::SolrResponseHash
27
- def self.same_number_of_results_body
28
- lambda { |expected_solr_resp_hash|
5
+ def self.same_number_of_results_body
6
+ lambda do |expected_solr_resp_hash|
29
7
  match do |actual_solr_resp_hash|
30
8
  actual_solr_resp_hash.size == expected_solr_resp_hash.size
31
9
  end
32
10
 
33
- failure_message_for_should do |actual_solr_resp_hash|
11
+ failure_message do |actual_solr_resp_hash|
34
12
  "expected #{actual_solr_resp_hash.size} documents in Solr response #{expected_solr_resp_hash.num_docs_partial_output_str}"
35
13
  end
36
-
37
- failure_message_for_should_not do |actual_solr_resp_hash|
14
+
15
+ failure_message_when_negated do |actual_solr_resp_hash|
38
16
  "expected (not #{actual_solr_resp_hash.size}) documents in Solr response #{expected_solr_resp_hash.num_docs_partial_output_str}"
39
- end
40
-
17
+ end
18
+
41
19
  diffable
42
- }
43
- end
44
-
20
+ end
21
+ end
22
+
23
+ # @!method have_the_same_number_of_results_as
45
24
  # Determine if the receiver (a Solr response object) has the same number of total documents as the expected RSpecSolr::SolrResponseHash
46
25
  # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
47
26
  RSpec::Matchers.define :have_the_same_number_of_results_as, &same_number_of_results_body
48
27
 
28
+ # @!method have_the_same_number_of_documents_as
49
29
  # Determine if the receiver (a Solr response object) has the same number of total documents as the expected RSpecSolr::SolrResponseHash
50
30
  # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
51
31
  RSpec::Matchers.define :have_the_same_number_of_documents_as, &same_number_of_results_body
52
-
53
- # this is the lambda used to determine if the receiver (a Solr response object) has fewer total documents
32
+
33
+ # this is the lambda used to determine if the receiver (a Solr response object) has fewer total documents
54
34
  # than the expected RSpecSolr::SolrResponseHash
55
35
  def self.fewer_results_than_body
56
- lambda { |expected_solr_resp_hash|
36
+ lambda do |expected_solr_resp_hash|
57
37
  match do |actual_solr_resp_hash|
58
38
  actual_solr_resp_hash.size < expected_solr_resp_hash.size
59
39
  end
60
40
 
61
- failure_message_for_should do |actual_solr_resp_hash|
41
+ failure_message do |actual_solr_resp_hash|
62
42
  "expected more than #{actual_solr_resp_hash.size} documents in Solr response #{expected_solr_resp_hash.num_docs_partial_output_str}"
63
43
  end
64
44
 
65
- failure_message_for_should_not do |actual_solr_resp_hash|
45
+ failure_message_when_negated do |actual_solr_resp_hash|
66
46
  "expected #{actual_solr_resp_hash.size} or fewer documents in Solr response #{expected_solr_resp_hash.num_docs_partial_output_str}"
67
- end
47
+ end
68
48
 
69
49
  diffable
70
- }
50
+ end
71
51
  end
72
-
52
+
53
+ # @!method have_fewer_results_than
73
54
  # Determine if the receiver (a Solr response object) has fewer total documents than the expected RSpecSolr::SolrResponseHash
74
55
  # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
75
56
  RSpec::Matchers.define :have_fewer_results_than, &fewer_results_than_body
76
57
 
58
+ # @!method have_fewer_documents_than
77
59
  # Determine if the receiver (a Solr response object) has fewer total documents than the expected RSpecSolr::SolrResponseHash
78
60
  # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
79
61
  RSpec::Matchers.define :have_fewer_documents_than, &fewer_results_than_body
80
62
 
81
- # this is the lambda used to determine if the receiver (a Solr response object) has more total documents
63
+ # this is the lambda used to determine if the receiver (a Solr response object) has more total documents
82
64
  # than the expected RSpecSolr::SolrResponseHash
83
65
  def self.more_results_than_body
84
- lambda { |expected_solr_resp_hash|
66
+ lambda do |expected_solr_resp_hash|
85
67
  match do |actual_solr_resp_hash|
86
68
  actual_solr_resp_hash.size > expected_solr_resp_hash.size
87
69
  end
88
70
 
89
- failure_message_for_should do |actual_solr_resp_hash|
71
+ failure_message do |actual_solr_resp_hash|
90
72
  "expected fewer than #{actual_solr_resp_hash.size} documents in Solr response #{expected_solr_resp_hash.num_docs_partial_output_str}"
91
73
  end
92
74
 
93
- failure_message_for_should_not do |actual_solr_resp_hash|
75
+ failure_message_when_negated do |actual_solr_resp_hash|
94
76
  "expected #{actual_solr_resp_hash.size} or more documents in Solr response #{expected_solr_resp_hash.num_docs_partial_output_str}"
95
- end
77
+ end
96
78
 
97
79
  diffable
98
- }
80
+ end
99
81
  end
100
82
 
83
+ # @!method have_more_results_than
101
84
  # Determine if the receiver (a Solr response object) has more total documents than the expected RSpecSolr::SolrResponseHash
102
85
  # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
103
86
  RSpec::Matchers.define :have_more_results_than, &more_results_than_body
104
87
 
88
+ # @!method have_more_documents_than
105
89
  # Determine if the receiver (a Solr response object) has more total documents than the expected RSpecSolr::SolrResponseHash
106
90
  # NOTE: this is about the TOTAL number of Solr documents matching the queries, not solely the number of docs in THESE responses
107
91
  RSpec::Matchers.define :have_more_documents_than, &more_results_than_body
108
-
109
- end
92
+ end