Sha256: 2f6bb7c39da851512e8c626f6defe749990843babd539761aa97c66c85f56ae1
Contents?: true
Size: 780 Bytes
Versions: 10
Compression:
Stored size: 780 Bytes
Contents
# frozen_string_literal: true require "spec_helper" module Trailblazer class Finder module Utils describe Hash do let(:hash) do [{id: 1, value: "Test 1"}, {id: 2, value: "Test 2"}, {id: 3, value: ""}, {id: 4, value: "Test 4"}] end describe ".deep_locate" do it "locates enumerables for which the given comparator returns true for at least one element" do expect(described_class.deep_locate(->(k, v, _) { k == :value && v.to_s == "Test 2" && !v.nil? }, hash)) .to eq [{id: 2, value: "Test 2"}] end end it "returns an empty array if nothing was found" do expect(described_class.deep_locate(:muff, foo: "bar")).to eq([]) end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems