summaryrefslogtreecommitdiff
path: root/spec/hashie/extensions/stringify_keys_spec.rb
diff options
context:
space:
mode:
authorVincent Esche <vincent.esche@namics.com>2015-06-05 18:48:09 +0200
committerVincent Esche <regexident@gmail.com>2015-06-08 02:01:54 +0200
commit489309af7ffd8b4fe02bd839924b319cba8aa318 (patch)
tree56a2667e2deef61ba389c9a1a8b219fe44bb65ee /spec/hashie/extensions/stringify_keys_spec.rb
parentb7405dca6d8d03c1650083119215a6eaf4125d91 (diff)
downloadhashie-489309af7ffd8b4fe02bd839924b319cba8aa318.tar.gz
Fix bug (#303) preventing use of deep_merge/stringify_keys/symbolize_keys on extended singleton objects.
Diffstat (limited to 'spec/hashie/extensions/stringify_keys_spec.rb')
-rw-r--r--spec/hashie/extensions/stringify_keys_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/hashie/extensions/stringify_keys_spec.rb b/spec/hashie/extensions/stringify_keys_spec.rb
index b0f8aa6..f5f78d8 100644
--- a/spec/hashie/extensions/stringify_keys_spec.rb
+++ b/spec/hashie/extensions/stringify_keys_spec.rb
@@ -80,6 +80,29 @@ describe Hashie::Extensions::StringifyKeys do
include_examples 'stringify_keys!'
end
end
+
+ context 'singleton methods' do
+ subject { Hash }
+ let(:object) { subject.new.merge(a: 1, b: { c: 2 }).extend(Hashie::Extensions::StringifyKeys) }
+ let(:expected_hash) { { 'a' => 1, 'b' => { 'c' => 2 } } }
+
+ describe '.stringify_keys' do
+ it 'does not raise error' do
+ expect { object.stringify_keys } .not_to raise_error
+ end
+ it 'produces expected stringified hash' do
+ expect(object.stringify_keys).to eq(expected_hash)
+ end
+ end
+ describe '.stringify_keys!' do
+ it 'does not raise error' do
+ expect { object.stringify_keys! } .not_to raise_error
+ end
+ it 'produces expected stringified hash' do
+ expect(object.stringify_keys!).to eq(expected_hash)
+ end
+ end
+ end
end
describe Hashie do