Açık olan bir şey eksik olan Noob ... Bir Rspec dosyasında hata ayıklamaya çalışıyorum. Ruby Hata ayıklama "Yüklenecek dosya yok --spec_helper"
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
komut satırından aşağıdaki arama yapmak: RSpec dosyası bu noktada şeritli
rdebug spec/controllers/pages_controller_spec.rb
ayıklayıcı çalışır, ancak aşağıdaki hatayı atar:
> 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/[email protected]/gems/ruby-debug19-0.11.6/bin/rdebug:125:in `debug_load'
/home/kevin/.rvm/gems/[email protected]/gems/ruby-debug19-0.11.6/bin/rdebug:125:in `debug_program'
/home/kevin/.rvm/gems/[email protected]/gems/ruby-debug19-0.11.6/bin/rdebug:412:in `<top (required)>'
/home/kevin/.rvm/gems/[email protected]/bin/rdebug:19:in `load'
/home/kevin/.rvm/gems/r[email protected]/bin/rdebug:19:in `<main>'
Uncaught exception: no such file to load -- spec_helper
Rspec hata ayıklayıcı olmadan bir sorun olmadan. Rspec 2.3.0, ruby-debug19 (0.11.6), Rails 3.0.3 ve ruby 1.9.2 kullanıyorum. Neden debugger spec_helper dosyasını göremiyor?
Harikasınız. Evet, işe yarıyor. Bu durumda require_relative neden gereklidir? – Kevin
'require', diğer diziler arasında, geçerli dizininizde, aradığınız dosyaya göre' require_relative 'aramalarını arar. Eski yol, File.expand_path gerektiriyordu ("# {File.dirname (__ FILE__))} /../ spec_helper ") '. Yani birisi daha kullanışlı 'require_relative' ile geldi. – rausch
Harika bir açıklama - teşekkürler. – Kevin