1

我正在尝试在我应该收到错误的 ruby​​ 文件上运行 rake,以便我可以将其作为练习进行调试。但是我得到的错误不是我应该收到的错误。我收到以下内容,我正在花时间解释我需要解决的问题。

~Desktop/learn_ruby-master/00_hello$ rake
(in /~Desktop/learn_ruby-master)
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file --     hello (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from ~Desktop/learn_ruby-master/00_hello/hello_spec.rb:117:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in     `block in autorun'

耙中止!

/usr/bin/ruby1.9.1 -S rspec ~Desktop/learn_ruby-master/00_hello/hello_spec.rb -    I/~Desktop/learn_ruby-master/00_hello -I/~Desktop/learn_ruby-master/00_hello/solution -f     documentation -r ./rspec_config failed

Tasks: TOP => default => spec
(    See full trace by running task with --trace)

这是我正在运行 rake 的代码

    require "hello"

describe "the hello function" do
  it "says hello" do
    hello.should == "Hello!"
  end
end

describe "the greet function" do
  it "says hello to someone" do
    greet("Alice").should == "Hello, Alice!"
  end

  it "says hello to someone else" do
    greet("Bob").should == "Hello, Bob!"
  end
end
4

2 回答 2

2

I had the same problem (going through the exact same tutorial). I just spent three days of my life trying to figure it out. The issue was that one of my folders in the path to 'hello.rb' had a space in between two words. Seriously, that was it. The ruby path couldn't pick it up no matter what I did (except change the space). Uggh. Lesson learned, don't name anything, anywhere with a space from here on out.

于 2013-05-01T01:13:10.107 回答
1

Ruby 说明了一切:“在库加载路径上找不到文件名 hello.rb”。您缺少 hello.rb 文件或 Ruby 找不到它。你真的有它在你运行 rake 的目录中的光盘上吗?如果它在其他地方,您需要提供相对路径。

还要从第一行删除空格,我怀疑你那里有一些垃圾。错误消息中的 -- 和 hello 之间应该只有一个空格。

于 2013-03-15T14:48:00.890 回答