我最近安装了pry来替换我的irb。它一开始工作的很好,但现在每次运行pry时都根本无法识别本地应用程序环境。我得到类似如下: [3] pry(main)> show-models
NameError: undefined local variable or method `show' for main:Object
from (pry):2:in `__pry__'
我已经试过卸载并重新
我试图在RSpec中使用Pry。 目标是能够在方法中删除绑定并对其进行调试。 这是我的。 的lib/play.rb class Play
def self.hello
print 'Hello world!'
require 'pry'; binding.pry
end
end
规格/ play_spec.rb require_relative '..
我从了解计算书以下代码。目的是改变inspect的行为。 class Number < Struct.new(:value)
def inspect
"<<#{self}>>"
end
def to_s
value.to_s
end
end
它按预期工作当我使用irb: irb(main):014:0> Number.new(1)