Logo: Relish

  1. Sign in

Project: Right-support

tools for hash manipulation

In order to successfully work with hashes
RightSupport should have a tested set of tools
So the developers can trust each method

Scenarios
getting a value from a path
Given
a hash map with the form {"key1":"val1", "key2":{"key3":"val2"}}
And
a path array ["key2", "key3"]
When
I call the deep_get method
Then
The deep_get method response should be: val2
setting a value on a path
Given
a hash map with the form {"key1":{"key4":{"key5":"no"}}, "key2":{"key3":"val2"}}
And
a path array ["key1", "key4", "key5"]
And
a value val3
When
I call the deep_set! method
Then
The hash should be: {"key1":{"key4":{"key5":"val3"}}, "key2":{"key3":"val2"}}
merging two hashes
Given
a hash map with the form {"key1":"val1", "key2":{"key3":"val2"}}
When
I call the deep_merge! method with the source: {"key1":{"key4":"val3"}}
Then
The hash should be: {"key1":{"key4":"val3"}, "key2":{"key3":"val2"}}
subtracting a hash
Given
a hash map with the form {"key1":"val1", "key2":{"key3":"val2"}}
When
I call the deep_remove! method with the source: {"key1":"val1"}
Then
The hash should be: {"key2":{"key3":"val2"}}

Last published over 4 years ago by Tony Spataro.