diff options
author | dblock <dblock@dblock.org> | 2014-04-30 13:34:37 -0400 |
---|---|---|
committer | dblock <dblock@dblock.org> | 2014-04-30 21:00:01 -0400 |
commit | c982c75fb600de57ab47bde5df321585d4788163 (patch) | |
tree | db9c3bbea04f7bbafd2d1a285029e29c2db37b85 /spec | |
parent | 6bb94f89891f8035a77a5115880ba9096abfd4f8 (diff) | |
download | hashie-c982c75fb600de57ab47bde5df321585d4788163.tar.gz |
Reorganized extensions, consolidated Hashie StringifyKeys implementation.
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 |