Sha256: aeb069290f8c7b993e71a83bfa3feadd92e82f3e234084faf5ef9b51cd18f789

Contents?: true

Size: 991 Bytes

Versions: 20

Compression:

Stored size: 991 Bytes

Contents

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

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
elasticsearch-model-queryable-0.1.9 test/unit/response_results_test.rb
elasticsearch-model-queryable-0.1.5 test/unit/response_results_test.rb
elasticsearch-model-6.0.0.pre test/unit/response_results_test.rb
elasticsearch-model-5.1.0 test/unit/response_results_test.rb
elasticsearch-model-5.0.2 test/unit/response_results_test.rb
elasticsearch-model-2.0.1 test/unit/response_results_test.rb
elasticsearch-model-5.0.1 test/unit/response_results_test.rb
elasticsearch-model-2.0.0 test/unit/response_results_test.rb
elasticsearch-model-5.0.0 test/unit/response_results_test.rb
elasticsearch-model-0.1.9 test/unit/response_results_test.rb
elasticsearch-model-0.1.8 test/unit/response_results_test.rb
elasticsearch-model-0.1.7 test/unit/response_results_test.rb
elasticsearch-model-0.1.6 test/unit/response_results_test.rb
elasticsearch-model-0.1.5 test/unit/response_results_test.rb
elasticsearch-model-0.1.4 test/unit/response_results_test.rb
elasticsearch-model-0.1.3 test/unit/response_results_test.rb
elasticsearch-model-0.1.2 test/unit/response_results_test.rb
elasticsearch-model-0.1.1 test/unit/response_results_test.rb
elasticsearch-model-0.1.0 test/unit/response_results_test.rb
elasticsearch-model-0.1.0.rc1 test/unit/response_results_test.rb