Sha256: 70c9a074a3e01f627eb25f0ed1090c6170e488c3efd7778514717a3f12dd1542
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require "celsius/hash" describe Celsius::Hash do describe ".deep_find_key" do let(:hash) do { query: { bool: [ { query_string: { query: "a" } }, { query_string: { query: "b" } }, { match: { some_field: "some_value" } } ] }, facets: { creator: { terms: { field: "facet_creator" } }, lang: { terms: { field: "facet_lang", } } } } end it "returns values matching the given key" do expected_result = [ hash[:query][:bool][0][:query_string], hash[:query][:bool][1][:query_string], ] expect(described_class.deep_find_key(hash, :query_string)).to eq(expected_result) end context "if given an array of keys" do it "tries to find each element based on the former elements result" do expected_result = [ hash[:facets][:creator] ] expect(described_class.deep_find_key(hash, [:facets, :creator])).to eq(expected_result) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
celsius-0.4.0 | spec/celsius/hash_spec.rb |