How to run IRB.start in context of current class

后端 未结 8 1018
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 21:23

I\'ve been just going through PragProg Continuous Testing With Ruby, where they talk about invoking IRB in context of current class to inspect the code

8条回答
  •  醉话见心
    2020-12-29 22:04

    As of Ruby 2.4.0, you can do this:

    require 'irb'
    binding.irb
    

    This will start an IBR REPL where you will have the correct value for self and you will be able to access all local variables and instance variables that are in scope. Type Ctrl+D or quit in order to resume your Ruby program.

提交回复
热议问题