spec/hashie/extensions/deep_find_spec.rb in hashie-3.4.6 vs spec/hashie/extensions/deep_find_spec.rb in hashie-3.5.0

- old
+ new

@@ -40,9 +40,34 @@ end it 'returns nil if it does not find any matches' do expect(instance.deep_find_all(:wahoo)).to be_nil end + + context 'when match value is hash itself' do + let(:hash) do + { + title: { + type: :string + }, + library: { + books: [ + { title: 'Call of the Wild' }, + { title: 'Moby Dick' } + ], + shelves: nil, + location: { + address: '123 Library St.', + title: 'Main Library' + } + } + } + end + + it 'detects all values from a nested hash' do + expect(instance.deep_find_all(:title)).to eq([{ type: :string }, 'Call of the Wild', 'Moby Dick', 'Main Library']) + end + end end context 'on an ActiveSupport::HashWithIndifferentAccess' do subject(:instance) { hash.with_indifferent_access.extend(Hashie::Extensions::DeepFind) }