Sha256: b45faa3e6ad866b34d3e49441c1db88f8443371039cffc853149ca10aa763188

Contents?: true

Size: 1.98 KB

Versions: 90

Compression:

Stored size: 1.98 KB

Contents

require 'test_helper'

require 'hashie'

module Elasticsearch
  module Test
    class HashieTest < ::Test::Unit::TestCase

      context "Hashie" do
        subject { FakeClient.new }

        should "wrap the response" do
          json =<<-JSON
            {
              "took": 14,
              "timed_out": false,
              "_shards": {
                "total": 1,
                "successful": 1,
                "failed": 0
              },
              "hits": {
                "total": 5,
                "max_score": 0.51104903,
                "hits": [
                  {
                    "_index": "myindex",
                    "_type": "mytype",
                    "_id": "1",
                    "_score": 0.51104903,
                    "_source": {
                      "title": "Test 1",
                      "tags": [
                        "y",
                        "z"
                      ],
                      "published": true,
                      "published_at": "2013-06-22T21:13:00Z",
                      "counter": 1
                    }
                  }
                ]
              },
              "facets": {
                "tags": {
                  "_type": "terms",
                  "missing": 0,
                  "total": 10,
                  "other": 0,
                  "terms": [
                    {
                      "term": "z",
                      "count": 4
                    },
                    {
                      "term": "y",
                      "count": 3
                    },
                    {
                      "term": "x",
                      "count": 3
                    }
                  ]
                }
              }
            }
          JSON

          response = Hashie::Mash.new MultiJson.load(json)

          assert_equal 'Test 1', response.hits.hits.first._source.title
          assert_equal 'z',      response.facets.tags.terms.first.term
        end
      end

    end
  end
end

Version data entries

90 entries across 90 versions & 6 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/elasticsearch-api-5.0.5/test/unit/hashie_test.rb