|
6 | 6 | let(:config) { Blacklight::Configuration.new } |
7 | 7 |
|
8 | 8 | let(:r) do |
9 | | - Blacklight::Solr::Response.new(raw_response, |
10 | | - raw_response['params'], |
11 | | - blacklight_config: config) |
| 9 | + described_class.new(raw_response, |
| 10 | + raw_response['params'], |
| 11 | + blacklight_config: config) |
12 | 12 | end |
13 | 13 |
|
14 | 14 | it 'creates a valid response' do |
|
113 | 113 | it 'provides the responseHeader params' do |
114 | 114 | raw_response = eval(mock_query_response) |
115 | 115 | raw_response['responseHeader']['params']['test'] = :test |
116 | | - r = Blacklight::Solr::Response.new(raw_response, raw_response['params']) |
| 116 | + r = described_class.new(raw_response, raw_response['params']) |
117 | 117 | expect(r.params['test']).to eq :test |
118 | 118 | end |
119 | 119 |
|
120 | 120 | it 'provides the solr-returned params and "rows" should be 11' do |
121 | 121 | raw_response = eval(mock_query_response) |
122 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 122 | + r = described_class.new(raw_response, {}) |
123 | 123 | expect(r.params[:rows].to_s).to eq '11' |
124 | 124 | expect(r.params[:sort]).to eq 'title_si asc, pub_date_si desc' |
125 | 125 | end |
126 | 126 |
|
127 | 127 | it 'provides the ruby request params if responseHeader["params"] does not exist' do |
128 | 128 | raw_response = eval(mock_query_response) |
129 | 129 | raw_response.delete 'responseHeader' |
130 | | - r = Blacklight::Solr::Response.new(raw_response, rows: 999, sort: 'score desc, pub_date_si desc, title_si asc') |
| 130 | + r = described_class.new(raw_response, rows: 999, sort: 'score desc, pub_date_si desc, title_si asc') |
131 | 131 | expect(r.params[:rows].to_s).to eq '999' |
132 | 132 | expect(r.params[:sort]).to eq 'score desc, pub_date_si desc, title_si asc' |
133 | 133 | end |
134 | 134 |
|
135 | 135 | it 'provides spelling suggestions for regular spellcheck results' do |
136 | 136 | raw_response = eval(mock_response_with_spellcheck) |
137 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 137 | + r = described_class.new(raw_response, {}) |
138 | 138 | expect(r.spelling.words).to include("dell") |
139 | 139 | expect(r.spelling.words).to include("ultrasharp") |
140 | 140 | end |
141 | 141 |
|
142 | 142 | it 'provides spelling suggestions for extended spellcheck results' do |
143 | 143 | raw_response = eval(mock_response_with_spellcheck_extended) |
144 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 144 | + r = described_class.new(raw_response, {}) |
145 | 145 | expect(r.spelling.words).to include("dell") |
146 | 146 | expect(r.spelling.words).to include("ultrasharp") |
147 | 147 | end |
148 | 148 |
|
149 | 149 | it 'provides no spelling suggestions when extended results and suggestion frequency is the same as original query frequency' do |
150 | 150 | raw_response = eval(mock_response_with_spellcheck_same_frequency) |
151 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 151 | + r = described_class.new(raw_response, {}) |
152 | 152 | expect(r.spelling.words).to eq [] |
153 | 153 | end |
154 | 154 |
|
155 | 155 | context "pre solr 5 spellcheck collation syntax" do |
156 | 156 | it 'provides spelling suggestions for a regular spellcheck results with a collation' do |
157 | 157 | raw_response = eval(mock_response_with_spellcheck_collation) |
158 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 158 | + r = described_class.new(raw_response, {}) |
159 | 159 | expect(r.spelling.words).to include("dell") |
160 | 160 | expect(r.spelling.words).to include("ultrasharp") |
161 | 161 | end |
162 | 162 |
|
163 | 163 | it 'provides spelling suggestion collation' do |
164 | 164 | raw_response = eval(mock_response_with_spellcheck_collation) |
165 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 165 | + r = described_class.new(raw_response, {}) |
166 | 166 | expect(r.spelling.collation).to eq 'dell ultrasharp' |
167 | 167 | end |
168 | 168 | end |
169 | 169 |
|
170 | 170 | context "solr 5 spellcheck collation syntax" do |
171 | 171 | it 'provides spelling suggestions for a regular spellcheck results with a collation' do |
172 | 172 | raw_response = eval(mock_response_with_spellcheck_collation_solr5) |
173 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 173 | + r = described_class.new(raw_response, {}) |
174 | 174 | expect(r.spelling.words).to include("dell") |
175 | 175 | expect(r.spelling.words).to include("ultrasharp") |
176 | 176 | end |
177 | 177 |
|
178 | 178 | it 'provides spelling suggestion collation' do |
179 | 179 | raw_response = eval(mock_response_with_spellcheck_collation_solr5) |
180 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 180 | + r = described_class.new(raw_response, {}) |
181 | 181 | expect(r.spelling.collation).to eq 'dell ultrasharp' |
182 | 182 | end |
183 | 183 | end |
184 | 184 |
|
185 | 185 | context 'solr 6.5 spellcheck collation syntax' do |
186 | 186 | it 'provides spelling suggestions for a regular spellcheck results with a collation' do |
187 | 187 | raw_response = eval(mock_response_with_spellcheck_collation_solr65) |
188 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 188 | + r = described_class.new(raw_response, {}) |
189 | 189 | expect(r.spelling.words).to include("dell") |
190 | 190 | expect(r.spelling.words).to include("ultrasharp") |
191 | 191 | end |
192 | 192 | end |
193 | 193 |
|
194 | 194 | it "provides MoreLikeThis suggestions" do |
195 | 195 | raw_response = eval(mock_response_with_more_like_this) |
196 | | - r = Blacklight::Solr::Response.new(raw_response, {}) |
| 196 | + r = described_class.new(raw_response, {}) |
197 | 197 | expect(r.more_like(double(id: '79930185'))).to have(2).items |
198 | 198 | end |
199 | 199 |
|
200 | 200 | it "is empty when the response has no results" do |
201 | | - r = Blacklight::Solr::Response.new({}, {}) |
| 201 | + r = described_class.new({}, {}) |
202 | 202 | allow(r).to receive_messages(total: 0) |
203 | 203 | expect(r).to be_empty |
204 | 204 | end |
205 | 205 |
|
206 | 206 | describe "#export_formats" do |
207 | 207 | it "collects the unique export formats for the current response" do |
208 | | - r = Blacklight::Solr::Response.new({}, {}) |
| 208 | + r = described_class.new({}, {}) |
209 | 209 | allow(r).to receive_messages(documents: [double(export_formats: { a: 1, b: 2 }), double(export_formats: { b: 1, c: 2 })]) |
210 | 210 | expect(r.export_formats).to include :a, :b |
211 | 211 | end |
|
0 commit comments