Ruby 调试“没有这样的文件加载 --spec_helper" [英] Ruby Debug "no such file to load --spec_helper"
问题描述
可能遗漏了一些明显的东西的菜鸟......我正在尝试调试 Rspec 文件.Rspec 文件此时被剥离:
Noob who may be missing something obvious ... I'm trying to debug an Rspec file. The Rspec file is stripped down at this point:
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
describe "when not signed in" do
before(:each) do
get :home
end
it "should be successful" do
response.should be_success
end
it "should have a vendor section" do
response.should have_selector("h1", :content => "Vendor")
end
it "should have a hospital section" do
response.should have_selector("h1", :content => "Hospital")
end
end
end
我从命令行进行以下调用:
I make the following call from the command line:
rdebug spec/controllers/pages_controller_spec.rb
调试器运行,但抛出以下错误:
The debugger runs, but throws the following error:
> require 'spec_helper'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/kevin/.rvm/bin/rails_projects/evaluationrx/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>'
/home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/ruby-debug19-0.11.6/bin/rdebug:125:in `debug_load'
/home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/ruby-debug19-0.11.6/bin/rdebug:125:in `debug_program'
/home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/ruby-debug19-0.11.6/bin/rdebug:412:in `<top (required)>'
/home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/bin/rdebug:19:in `load'
/home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/bin/rdebug:19:in `<main>'
Uncaught exception: no such file to load -- spec_helper
没有调试器的 Rspec 没有问题.我正在使用 Rspec 2.3.0、ruby-debug19 (0.11.6)、Rails 3.0.3 和 ruby 1.9.2.为什么调试器看不到spec_helper文件?
Rspec without the debugger without a problem. I'm using Rspec 2.3.0, ruby-debug19 (0.11.6), Rails 3.0.3 and ruby 1.9.2. Why can't the debugger see the spec_helper file?
推荐答案
我假设您的 spec_helper.rb 位于 spec 目录中?试试:
I assume your spec_helper.rb resides in the spec directory? Try:
require_relative '../spec_helper'
这篇关于Ruby 调试“没有这样的文件加载 --spec_helper"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!