Sha256: 5f44b39496b9eef173d20f441c8ef0caf08b08c008f99250657762184d3fd762

Contents?: true

Size: 735 Bytes

Versions: 13

Compression:

Stored size: 735 Bytes

Contents

require File.expand_path("../spec_helper", __dir__)

RSpec.describe SearchFlip::Result do
  describe ".from_hit" do
    it "adds a _hit key into _source and merges the hit keys into it" do
      result = SearchFlip::Result.from_hit("_score" => 1.0, "_source" => { "name" => "Some name" })

      expect(result).to eq("name" => "Some name", "_hit" => { "_score" => 1.0 })
    end

    it "allows deep method access" do
      result = SearchFlip::Result.from_hit("_source" => { "key1" => [{ "key2" => "value" }] })

      expect(result.key1[0].key2).to eq("value")
    end

    it "works with the _source being disabled" do
      result = SearchFlip::Result.from_hit("_id" => 1)

      expect(result._hit._id).to eq(1)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
search_flip-3.9.0 spec/search_flip/result_spec.rb
search_flip-3.8.0 spec/search_flip/result_spec.rb
search_flip-3.7.2 spec/search_flip/result_spec.rb
search_flip-3.7.1 spec/search_flip/result_spec.rb
search_flip-3.7.0 spec/search_flip/result_spec.rb
search_flip-3.6.0 spec/search_flip/result_spec.rb
search_flip-3.5.0 spec/search_flip/result_spec.rb
search_flip-3.4.0 spec/search_flip/result_spec.rb
search_flip-3.3.0 spec/search_flip/result_spec.rb
search_flip-3.2.1 spec/search_flip/result_spec.rb
search_flip-3.2.0 spec/search_flip/result_spec.rb
search_flip-3.1.2 spec/search_flip/result_spec.rb
search_flip-3.1.1 spec/search_flip/result_spec.rb