File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def merge!(hash)
112112 end
113113
114114 # Some keywords that don't play nicely with OpenStruct
115- SETTINGS_RESERVED_NAMES = %w[ select collect test count zip min max exit! ] . freeze
115+ SETTINGS_RESERVED_NAMES = %w[ select collect test count zip min max exit! table ] . freeze
116116
117117 # An alternative mechanism for property access.
118118 # This let's you do foo['bar'] along with foo.bar.
@@ -132,11 +132,11 @@ def []=(param, value)
132132 end
133133
134134 def key? ( key )
135- table . key? ( key )
135+ @ table. key? ( key )
136136 end
137137
138138 def has_key? ( key )
139- table . has_key? ( key )
139+ @ table. has_key? ( key )
140140 end
141141
142142 def method_missing ( method_name , *args )
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ zip: cherry
55max : kumquat
66min : fig
77exit! : taro
8+ table : strawberry
Original file line number Diff line number Diff line change 1818 expect ( config . max ) . to eq ( 'kumquat' )
1919 expect ( config . min ) . to eq ( 'fig' )
2020 expect ( config . exit! ) . to eq ( 'taro' )
21+ expect ( config . table ) . to eq ( 'strawberry' )
2122 end
2223
2324 it 'should allow to access them using [] operator' do
2829 expect ( config [ 'max' ] ) . to eq ( 'kumquat' )
2930 expect ( config [ 'min' ] ) . to eq ( 'fig' )
3031 expect ( config [ 'exit!' ] ) . to eq ( 'taro' )
32+ expect ( config [ 'table' ] ) . to eq ( 'strawberry' )
3133
3234 expect ( config [ :select ] ) . to eq ( 'apple' )
3335 expect ( config [ :collect ] ) . to eq ( 'banana' )
3638 expect ( config [ :max ] ) . to eq ( 'kumquat' )
3739 expect ( config [ :min ] ) . to eq ( 'fig' )
3840 expect ( config [ :exit! ] ) . to eq ( 'taro' )
41+ expect ( config [ :table ] ) . to eq ( 'strawberry' )
42+ end
43+
44+ context 'when empty' do
45+ let ( :config ) do
46+ Config . load_files ( "#{ fixture_path } /empty1.yml" )
47+ end
48+
49+ it 'should allow to access them via object member notation' do
50+ expect ( config . select ) . to be_nil
51+ expect ( config . table ) . to be_nil
52+ end
53+
54+ it 'should allow to access them using [] operator' do
55+ expect ( config [ 'select' ] ) . to be_nil
56+ expect ( config [ 'table' ] ) . to be_nil
57+
58+ expect ( config [ :select ] ) . to be_nil
59+ expect ( config [ :table ] ) . to be_nil
60+ end
3961 end
4062 end
4163
You can’t perform that action at this time.
0 commit comments