File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+
4+ class InheritingHashTest < ActiveSupport ::TestCase
5+ def setup
6+ @parent = ActiveResource ::InheritingHash . new ( { override_me : 'foo' , parent_key : 'parent_value' } )
7+ @child = ActiveResource ::InheritingHash . new ( @parent )
8+ @child [ :override_me ] = 'bar'
9+ @child [ :child_only ] = 'baz'
10+ end
11+
12+ def test_child_key_overrides_parent_key
13+ assert_equal 'bar' , @child [ :override_me ]
14+ end
15+
16+ def test_parent_key_available_on_lookup
17+ assert_equal 'parent_value' , @child [ :parent_key ]
18+ end
19+
20+ def test_conversion_to_regular_hash_includes_parent_keys
21+ hash = @child . to_hash
22+
23+ assert_equal 3 , hash . keys . length
24+ assert_equal 'parent_value' , hash [ :parent_key ]
25+ end
26+ end
You can’t perform that action at this time.
0 commit comments