我使用guard-rails来运行我的rails服务器,我的问题是当我添加binding.pry时,我不能访问REPL,我只是得到
From: /home/martinr/code/app/controllers/tools_controller.rb @ line 2 ToolsController#index:
2: def index
=> 3: binding.pry
4: @end_date = Date.today.to_s
5: @start_date = Date.today.months_ago(3).to_s
7: end
[1] pry(#<ToolsController>)> 没有REPL,我如何使用带有护栏的撬?
我的Gemfile文件如下所示
group :development, :test do
gem 'pry-rails' # for better console debugging
gem 'pry-debugger'
gem 'rb-inotify'
gem 'sqlite3'
end我的Guardfile:
guard 'rails', :debugger => true do
watch('Gemfile.lock')
watch(%r{^(config|lib)/.*})
end发布于 2013-07-18 17:44:25
我已经使用guard和Spork设置了我的rails环境,我发现绑定撬动与Guard的行为很奇怪。如果我将binding.pry插入到代码中,然后guard重新启动我的测试,就不会有交互式调试。但如果我退出并再次启动防护,它可以正常工作并正确地进入交互模式。
然而..。如果我随后删除了binding.pry行,guard将按预期重新运行测试,但会在绑定行曾经所在的位置中断,即使它已经不在那里。
似乎每次插入或移除撬绑时都必须重新启动guard。
令人恼火,但仍然比不能在测试中窥探要好。
发布于 2013-03-27 00:15:06
我正在尝试一个类似的东西,但也不能让它工作。问题似乎是从stdin读取数据不会阻塞,所以Pry不会阻塞。从STDIN读取的任何内容都会立即返回。
rspec -X console.rb文件如下:
require 'spec_helper'
describe 'console' do
it 'opens!' do
Pry.config.input = STDIN
Pry.config.output = STDOUT
puts STDIN.closed? # returns false
binding.pry # returns right away, does not block
gets # returns right way, does not block
end
endhttps://stackoverflow.com/questions/14153585
复制相似问题