forked from elastic/elasticsearch-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse_results_test.rb
31 lines (25 loc) · 991 Bytes
/
response_results_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test_helper'
class Elasticsearch::Model::ResultsTest < Test::Unit::TestCase
context "Response results" do
class OriginClass
def self.index_name; 'foo'; end
def self.document_type; 'bar'; end
end
RESPONSE = { 'hits' => { 'total' => 123, 'max_score' => 456, 'hits' => [{'foo' => 'bar'}] } }
setup do
@search = Elasticsearch::Model::Searching::SearchRequest.new OriginClass, '*'
@response = Elasticsearch::Model::Response::Response.new OriginClass, @search
@results = Elasticsearch::Model::Response::Results.new OriginClass, @response
@search.stubs(:execute!).returns(RESPONSE)
end
should "access the results" do
assert_respond_to @results, :results
assert_equal 1, @results.results.size
assert_equal 'bar', @results.results.first.foo
end
should "delegate Enumerable methods to results" do
assert ! @results.empty?
assert_equal 'bar', @results.first.foo
end
end
end