diff options
author | Martin Streicher <martin.streicher@gmail.com> | 2015-03-31 11:00:55 -0400 |
---|---|---|
committer | dB <dblock@dblock.org> | 2015-03-31 11:00:55 -0400 |
commit | 8998021867b0ffc55c99aca9dcf6c8f23fb33d7c (patch) | |
tree | d064c9080b34fea2333dc13fdce27568797985c9 /spec/hashie/extensions/coercion_spec.rb | |
parent | f29b37e8ed03017369daa62deea30c45a1165668 (diff) | |
download | hashie-8998021867b0ffc55c99aca9dcf6c8f23fb33d7c.tar.gz |
Fixed coercions in a subclass accumulating in the superclass.
Diffstat (limited to 'spec/hashie/extensions/coercion_spec.rb')
-rw-r--r-- | spec/hashie/extensions/coercion_spec.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/spec/hashie/extensions/coercion_spec.rb b/spec/hashie/extensions/coercion_spec.rb index 1de2d5d..1c45a55 100644 --- a/spec/hashie/extensions/coercion_spec.rb +++ b/spec/hashie/extensions/coercion_spec.rb @@ -406,17 +406,23 @@ describe Hashie::Extensions::Coercion do end context 'when subclassing' do - class MyHash < Hash + class MyOwnBase < Hash include Hashie::Extensions::Coercion + end + class MyOwnHash < MyOwnBase coerce_key :value, Integer end - class MySubclass < MyHash + class MyOwnSubclass < MyOwnHash end it 'inherits key coercions' do - expect(MyHash.key_coercions).to eql(MySubclass.key_coercions) + expect(MyOwnHash.key_coercions).to eql(MyOwnSubclass.key_coercions) + end + + it 'the superclass does not accumulate coerced attributes from subclasses' do + expect(MyOwnBase.key_coercions).to eq({}) end end end |