Sha256: f9d453055ef67497a68f56d222e418c606bdaa9c31e7ba50ca18070058d0c7c2

Contents?: true

Size: 1.21 KB

Versions: 21

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

class Elasticsearch::Model::BaseTest < Test::Unit::TestCase
  context "Response base module" do
    class OriginClass
      def self.index_name;    'foo'; end
      def self.document_type; 'bar'; end
    end

    class DummyBaseClass
      include Elasticsearch::Model::Response::Base
    end

    RESPONSE = { 'hits' => { 'total' => 123, 'max_score' => 456, 'hits' => [] } }

    setup do
      @search   = Elasticsearch::Model::Searching::SearchRequest.new OriginClass, '*'
      @response = Elasticsearch::Model::Response::Response.new OriginClass, @search
      @search.stubs(:execute!).returns(RESPONSE)
    end

    should "access klass, response, total and max_score" do
      r = DummyBaseClass.new OriginClass, @response

      assert_equal OriginClass, r.klass
      assert_equal @response, r.response
      assert_equal RESPONSE,  r.response.response
      assert_equal 123, r.total
      assert_equal 456, r.max_score
    end

    should "have abstract methods results and records" do
      r = DummyBaseClass.new OriginClass, @response

      assert_raise(Elasticsearch::Model::NotImplemented) { |e| r.results }
      assert_raise(Elasticsearch::Model::NotImplemented) { |e| r.records }
    end

  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

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