diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/hashie/hash_spec.rb | 6 | ||||
-rw-r--r-- | spec/hashie/mash_spec.rb | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/spec/hashie/hash_spec.rb b/spec/hashie/hash_spec.rb index c3da75b..0604d71 100644 --- a/spec/hashie/hash_spec.rb +++ b/spec/hashie/hash_spec.rb @@ -13,6 +13,12 @@ describe Hash do expect(hash).to eq Hashie::Hash['a' => 'hey', '123' => 'bob'] end + it '#stringify_keys! turns all keys into strings non-recursively' do + hash = Hashie::Hash[:a => 'hey', 123 => { 345 => 'hey' }] + hash.stringify_keys! + expect(hash).to eq Hashie::Hash['a' => 'hey', '123' => { 345 => 'hey' }] + end + it '#stringify_keys returns a hash with stringified keys' do hash = Hashie::Hash[:a => 'hey', 123 => 'bob'] stringified_hash = hash.stringify_keys diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb index 477ab42..122953f 100644 --- a/spec/hashie/mash_spec.rb +++ b/spec/hashie/mash_spec.rb @@ -469,4 +469,12 @@ describe Hashie::Mash do expect(mash.to_hash(symbolize_keys: true)[:outer].keys).not_to include('inner') end end + + describe '#stringify_keys' do + it 'turns all keys into strings recursively' do + hash = Hashie::Mash[:a => 'hey', 123 => { 345 => 'hey' }] + hash.stringify_keys! + expect(hash).to eq Hashie::Hash['a' => 'hey', '123' => { '345' => 'hey' }] + end + end end |