foxfire
foxfire

Reputation: 13

Problems running rake with rspec and ruby

I am trying to run rake on a ruby file where I am supposed to receive an error so I can debug it as an exercise. However the error I get is not the error Im supposed to receive. I'm receiving the following and I'm having a time interpreting what I need to fix.

~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'

rake aborted!

/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)

Here is the code I am running rake on

    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

Upvotes: 1

Views: 1013

Answers (2)

tbone
tbone

Reputation: 882

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.

Upvotes: 2

lzap
lzap

Reputation: 17174

Ruby says it all: "Cannot find filename hello.rb on the library loading path". You are missing hello.rb file or Ruby cannot find it. Do you really have it on the disc in the directory you run rake from? If its somewhere else you need to provide relative path.

Also remove the whitespace from the first line, I suspect you have some gargabe there. There should be only one space between -- and hello in the error message.

Upvotes: 1

Related Questions