3

I'm struggeling with RSpec, I just can't get RSpec to work in my Ruby project. Not even in the easy example provided in the "Get Started Now" section of the official homepage of RSpec: http://rspec.info/

So I take the code from the official example and create bowling.rb and bowling_spec.rb. When i try to run rspec from the console with:

rspec bowling_spec.rb --format nested

I get this output:

require': no such file to load -- bowling (LoadError)
from C:/.../Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/.../bowling_spec.rb:2:in `<top (required)>'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'

I tried to run RSpec on my own project with Netbans 7.0.1 as well as with Aptanda Studio 3. I always get this same error. The gem list show the following rspec gems:

  • rspec (2.6.0)
  • rspec-core (2.6.4)
  • rspec-expectations (2.6.0)
  • rspec-mocks (2.6.0)
  • rspec-rails (2.6.1)
  • rspec-rails-controller (0.1.2)

Can anybody help me with this?

3
  • 1
    Solved it when working with the command line. You have to put the bowling_spec.rb in spec/bowling_spec.rb and the bowling.rb in lib/bowling.rb for it to work. For Netbeans and Aptana i still get the same error though. Commented Oct 15, 2011 at 20:17
  • 1
    Are you using require 'bowling' (or require 'bowling.rb') to load the file? If so, you might want to use require './path/to/bowling.rb' or add your lib directory to your load path. Commented Oct 15, 2011 at 20:47
  • You should rarely need to require a .rb directly. And if you do, you should probably know why you're doing it. Commented Oct 16, 2011 at 0:55

2 Answers 2

1

The Solution for getting it to work in Netbeans too is to maunally install Rspec, since Netbeans doesn't have RSpec Version 2 support:

gem install rspec -v 1.3.2
Sign up to request clarification or add additional context in comments.

Comments

1

For posterity, I had this problem, too, and the issue was that I had accidentally require'ed spec_helper.rb in a non-spec class in a gem. That was fun to find.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.