summaryrefslogtreecommitdiff
path: root/spec/logic/helpers
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2023-05-13 18:51:02 -0300
committericebaker <icebaker@proton.me>2023-05-13 18:51:02 -0300
commit1fbdb24fff7cd84b5506cb0c7092fdcdc867ec12 (patch)
treed5d815cae646002f4833439d07c36bf9c1f68ed7 /spec/logic/helpers
parent62939e4baafde86d0ef599f1c7dc07cce95b8a73 (diff)
adding missing files
Diffstat (limited to 'spec/logic/helpers')
-rw-r--r--spec/logic/helpers/hash_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/logic/helpers/hash_spec.rb b/spec/logic/helpers/hash_spec.rb
new file mode 100644
index 0000000..09012c8
--- /dev/null
+++ b/spec/logic/helpers/hash_spec.rb
@@ -0,0 +1,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