【问题标题】:rspec error when running rake运行 rake 时出现 rspec 错误
【发布时间】:2013-09-28 22:05:37
【问题描述】:

我是一个菜鸟,正在学习这里很多人可能知道的教程 (testfirst.org)。当我尝试运行“rake”时,我在 terminal.app 中收到以下错误:

    fname-lnames-macbook-pro:00_hello macbookowner$ rake
    (in /Users/macbookowner/Desktop/learn_ruby-master)
    /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /Users in PATH, mode 040777
    /Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb:116:in `require': cannot load such file -- hello (LoadError)
        from /Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb:116:in `<top (required)>'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `each'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load_spec_files'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:22:in `run'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:80:in `run'
        from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:17:in `block in autorun'
    /Users/macbookowner/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -S rspec /Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb -I/Users/macbookowner/Desktop/learn_ruby-master/00_hello -I/Users/macbookowner/Desktop/learn_ruby-master/00_hello/solution -f documentation -r ./rspec_config failed
    fname-lnames-macbook-pro:00_hello macbookowner$ 

我的问题:出了什么问题?我该如何解决?

信息:

  1. 我在运行 rvm 1.9.3 和 rvm 2.0.0 时遇到相同/类似的错误
  2. 我在两个 rvm 版本上都安装了“gem install rspec”
  3. 我最好的猜测是 rake 找不到 hello.rb 文件 [我在 Sublime Text 2 中创建并保存在 macbookowner ->Desktop 上]。当我在桌面上运行 ls 时,它确实显示 hello.rb。

提前致谢!

【问题讨论】:

  • 请将代码发布到您的 hello.rb 文件中。看起来您有一行显示 require 'hello',而 ruby​​ 很难找到。
  • @Momer:好的,这里是来自 hello.rb 文件的代码(非常基本):'def hello "Hello!"结束'
  • 从hello.rb 和hello_spec.rb 粘贴您的代码,并在上面的问题中列出每个文件的路径。
  • @Momer。除了hello.rb,我实际上没有写任何东西。 hello_spec.rb 一定是他们写在 00_hello 文件中的东西?
  • @Momer。 hello.rb 的路径是 /Users/macbookowner/Desktop/hello.rb

标签: ruby rspec rake


【解决方案1】:

如果你查看错误,

/Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb:116:in 'require': cannot load such file -- hello (LoadError) 

它显示在 hello_spec.rb 的第 116 行,有一条 require 'hello' 语句失败。该文件可能在指定的路径中不存在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-17
    • 2012-11-23
    • 1970-01-01
    相关资源
    最近更新 更多