在“要求"中:没有要加载的此类文件--spec_helper [英] in 'require': no such file to load -- spec_helper

查看:29
本文介绍了在“要求"中:没有要加载的此类文件--spec_helper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 jruby 1.6 的 Windows 平台上使用 rspec 尝试 ruby​​ on rails 教程部分时遇到此错误:

Came across this error when trying out the ruby on rails tutorial section with rspec on a windows platform using jruby 1.6:

c:\rails_projects\sample_app>bundle exec rspec spec/
org/jruby/RubyKernel.java:1038:in `require': no such file to load -- spec_helper
 (LoadError)
        from c:/rails_projects/sample_app/spec/controllers/pages_controller_spec    .rb:1:in `(root)'
        from org/jruby/RubyKernel.java:1063:in `load'
        from c:/rails_projects/sample_app/spec/controllers/pages_controller_spec
.rb:386:in `load_spec_files'
        from org/jruby/RubyArray.java:2458:in `collect'
        from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe
c/core/configuration.rb:386:in `load_spec_files'
        from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe
c/core/command_line.rb:18:in `run'
        from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe
c/core/runner.rb:55:in `run_in_process'
        from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe
c/core/runner.rb:46:in `run'
        from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe
c/core/runner.rb:10:in `autorun'
        from org/jruby/RubyProc.java:268:in `call'
        from org/jruby/RubyProc.java:232:in `call'

找到了教程中似乎缺少的答案:

Found the answer which appears missing from the tutorial:

c:\rails_projects\sample_app>rails 生成 rspec:install

c:\rails_projects\sample_app>rails generate rspec:install

推荐答案

运行后

rails generate rspec:install

将您的 *_spec.rb 文件放在(在您的示例中)c:\rails_projects\sample_app\spec\model 下.然后用 require_relative 指定相对路径

Place your *_spec.rb files under (in your example) c:\rails_projects\sample_app\spec\model. Then specify relative path with require_relative

require_relative '../spec_helper'

这篇关于在“要求"中:没有要加载的此类文件--spec_helper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆