splitwise/super_diff

controller test broken: eval error: undefined method `keys' for nil:NilClass

Closed this issue · 3 comments

We have a pretty straight forward controller test that breaks execution

   context 'with the user not logged in' do
      context 'when the operation name contains "private"' do
         it 'returns a 403' do
           post :execute, as: :json, params: { query:, operationName: 'whatever-private' }

           expect(response).to be_forbidden # < boom; and response.forbidden? is false
         end
      end

The exception bubble up from ruby/gems/3.2.0/gems/super_diff-0.10.0/lib/super_diff/object_inspection/inspection_tree.rb:72 in `insert_hash_inspection_of'.

jas14 commented

This looks like a duplicate of #163 based on the last stack trace frame, does that seem right @fwolfst ?

jas14 commented

I was able to reproduce with a very simple app and may have found the culprit: ActiveSupport::OrderedOptions. This class specifically defines respond_to_missing? as true for everything. Thus, SuperDiff's InspectionTreeBuilders::CustomObject will be mistakenly applied to OrderedOptions, which will call insert_hash_inspection_of(nil), which will raise as described.

Sorry for having been mute. Awesome @jas14 and @mcmire ; thank you.