Your environment
ruby -v: ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux]rdbg -v: rdbg 1.11.0
Describe the bug
Object inspection doesn't work inside Mocks that doesn't expect the singleton_class method called
unmocked method :singleton_class
To Reproduce
You can try to reproduce it using a minitest Mock
mock=Minitest::Mock.newmock.expect:call,truedo |*passed_args, **passed_kwargs|
debuggerendmock.call(123)
Or make your own mock class from scratch (of course is not the same as minitest but mimics it)
classMockdefinitialize@expected={}enddefexpect(name,return_value=nil,expected_args=nil, &block)@expected[name.to_sym]=[return_value,expected_args,block]selfenddefmethod_missing(name, *args, **kwargs, &blk)entry=@expected[name.to_sym]raiseNoMethodError,"unmocked method #{name.inspect}, expected one of #{@expected.keys.inspect}"unlessentryreturn_value,expected_args,stored_block=entryreturnstored_block.call(*args, **kwargs)ifstored_blockreturn_valueenddefrespond_to_missing?(name,include_private=false)@expected.key?(name.to_sym) || superenddefsingleton_classmethod_missing(:singleton_class)endendmock=Mock.newmock.expect:call,truedo |*passed_args, **passed_kwargs|
debuggerendmock.call(123)Expected behavior
It should stop at the debugger, instead we get an error ``full_message': unmocked method :singleton_class, expected one of [:call] (NoMethodError)`
Additional context
I don't really know if this is a problem of MiniTest or from this gem, but binding.pry does not seem to fall into this error. Additionally i have identified that the code dies at lib/debug/frame_info.rb:172 where NoMethodError is not captured, although after inside safe_ispect it is captured, i don't really understand the flow of the gem but maybe we can skip the NoMethodError before safe inspecting. Lastly, i was eager to do a PR but i can't test because i'm on wsl2 and have no fast way of switching to linux at the moment.
Your environment
ruby -v: ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux]rdbg -v: rdbg 1.11.0Describe the bug
Object inspection doesn't work inside Mocks that doesn't expect the
singleton_classmethod calledunmocked method :singleton_classTo Reproduce
You can try to reproduce it using a minitest Mock
Or make your own mock class from scratch (of course is not the same as minitest but mimics it)
Expected behavior
It should stop at the debugger, instead we get an error ``full_message': unmocked method :singleton_class, expected one of [:call] (NoMethodError)`
Additional context
I don't really know if this is a problem of MiniTest or from this gem, but
binding.prydoes not seem to fall into this error. Additionally i have identified that the code dies atlib/debug/frame_info.rb:172whereNoMethodErroris not captured, although after insidesafe_ispectit is captured, i don't really understand the flow of the gem but maybe we can skip theNoMethodErrorbefore safe inspecting. Lastly, i was eager to do a PR but i can't test because i'm on wsl2 and have no fast way of switching to linux at the moment.