我目前收到如下错误:
NoMethodError: undefined method `debug' for nil:NilClass
/mnt/hgfs/Dropbox/Company/Project/lib/project/misc.rb:23:in `debug'
/mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:49:in `block in compare_addresses'
/mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:43:in `each'
/mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:43:in `compare_addresses'
/mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:32:in `valid?'
/mnt/hgfs/Dropbox/Company/Project/specs/project/validation/google_geocoding_validation_engine_spec.rb:56:in `block (2 levels) in <module:Validation>'
/home/tomas/ruby2/lib/ruby/2.0.0/minitest/unit.rb:1301:in `run'
我想我会尝试使用byebug来找出对象为什么是,nil
因为它不应该是nil
. 我放在byebug
错误线的正上方:
def debug(&block)
if @logger.nil?
byebug
end
@logger.debug(@logger_name, &block)
end
并进行了测试。我被丢到了 byebug 调试界面,可以确认对象确实是nil
. 问题是我无法爬上堆栈:
(byebug) up
*** Adjusting would put us beyond the oldest (initial) frame.
(byebug) down
*** Adjusting would put us beyond the newest (innermost) frame.
(byebug) backtrace
--> #0 AddressKit::Misc::Logging.debug(block#Proc) at /mnt/hgfs/Dropbox/Kvantel/Address Kit/lib/addresskit/misc.rb:25
Warning: saved frames may be incomplete; compare with caller(0)
为什么我不能上栈?这是 byebug 的问题还是与 MiniTest 不兼容?