spec/repository/response/results_spec.rb in elasticsearch-persistence-6.0.0.pre vs spec/repository/response/results_spec.rb in elasticsearch-persistence-6.0.0
- old
+ new
@@ -64,10 +64,26 @@
end
it 'wraps the response in a HashWrapper' do
expect(results.response._shards.total).to eq(5)
end
+
+ context 'when the response method is not called' do
+
+ it 'does not create an instance of HashWrapper' do
+ expect(Elasticsearch::Model::HashWrapper).not_to receive(:new)
+ results
+ end
+ end
+
+ context 'when the response method is called' do
+
+ it 'does create an instance of HashWrapper' do
+ expect(Elasticsearch::Model::HashWrapper).to receive(:new)
+ results.response
+ end
+ end
end
describe '#total' do
it 'returns the total' do
@@ -98,8 +114,15 @@
describe '#map_with_hit' do
it 'returns the result of the block called on a pair of each raw document and the deserialized object' do
expect(results.map_with_hit { |pair| pair[0] }).to eq(['Object', 'Object'])
+ end
+ end
+
+ describe '#raw_response' do
+
+ it 'returns the raw response from Elasticsearch' do
+ expect(results.raw_response).to eq(response)
end
end
end