簡體   English   中英

使用rspec和ruby運行rake的問題

[英]Problems running rake with rspec and ruby

我試圖在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)

這是我正在運行的代碼

    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

我有同樣的問題(通過完全相同的教程)。 我只花了三天時間試圖解決這個問題。 問題是我的'hello.rb'路徑中的一個文件夾在兩個單詞之間有一個空格。 說真的,就是這樣。 無論我做了什么(除了改變空間),紅寶石路徑都無法撿起它。 Uggh。 經驗教訓,不要在任何地方命名任何東西,從這里開始有空間。

Ruby說的都是:“在庫加載路徑上找不到文件名hello.rb”。 你缺少hello.rb文件或Ruby無法找到它。 你真的把它放在你運行rake的目錄中的光盤上嗎? 如果它在其他地方你需要提供相對路徑。

同時從第一行刪除空格,我懷疑你有一些gargabe。 錯誤消息中的 - 和hello之間應該只有一個空格。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM