blob: 09012c819b5a46e8ef135a573da018c171c1aae9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# frozen_string_literal: true
require_relative '../../../logic/helpers/hash'
RSpec.describe NanoBot::Logic::Helpers::Hash do
it 'symbolizes keys' do
expect(described_class.symbolize_keys({ 'a' => 'b', 'c' => { 'd' => ['e'] } })).to eq(
{ a: 'b', c: { d: ['e'] } }
)
expect(described_class.fetch({ a: 'b', c: { d: ['e'] } }, %i[c d])).to eq(
['e']
)
expect(described_class.fetch({ a: 'b', c: { d: ['e'] } }, %i[c e])).to be_nil
expect(described_class.fetch({ a: 'b', c: { d: ['e'] } }, %i[a b])).to be_nil
end
end
|