File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def [](key)
4646 end
4747
4848 def []=( key , value )
49- super ( key , value . is_a? ( Hash ) ? self . class . new ( value , { } ) : value )
49+ super ( key . to_sym , value . is_a? ( Hash ) ? self . class . new ( value , { } ) : value )
5050 end
5151
5252 def respond_to? ( name )
Original file line number Diff line number Diff line change @@ -77,6 +77,18 @@ def teardown
7777 assert_equal 'foo' , hashr . foo
7878 end
7979
80+ test 'method using a string key works' do
81+ hashr = Hashr . new
82+ hashr [ 'foo' ] = 'foo'
83+ assert_equal 'foo' , hashr . foo
84+ end
85+
86+ test 'using a symbol key works' do
87+ hashr = Hashr . new
88+ hashr [ :foo ] = 'foo'
89+ assert_equal 'foo' , hashr . foo
90+ end
91+
8092 test 'defining defaults' do
8193 klass = Class . new ( Hashr ) do
8294 define :foo => 'foo' , :bar => { :baz => 'baz' }
You can’t perform that action at this time.
0 commit comments