Am I missing Something? I can't get the simplest ruby project to work.

Using EAP 8858, and ruby plugin 2.0.208452

I create a simple ruby project over an existing source tree

directory structure looks like this:


the contents of foo_spec.rb are as follows

require 'foo'

When I try to run the spec runner, it complains that it cannot find 'foo.rb', but I cannot for the life of me figure out how to put 'lib' in the load path. having ruby sources in the 'lib' directory of the module root is very standard, so I would reckon that idea should include it by default, but even lacking that, I think you should be able to add it manually.

I feel like I'm missing something incredibly obvious, but I've been fighting this for over an hour, and can't figure out how to do it.

Comment actions Permalink

Hi Charles,

I suggest you to create lib/spec_helper.rb file with content

thus in lib/foo_spec.rb you should require helper file

This solution will work fine if you run it from IDE/Command line/on your build server

Comment actions Permalink


Thank you for replying.

That's what I ended up doing, although it would be nice to not have to do this. Are the plans to support this in the future?

other solutions I came up with that worked were:

  • adding my lib directory as a module library.

  • adding my lib directory to the RUBYLIB environment variable in the default run profile.

Keep up the great work. I still prefer textmate by just a hair, but hopefully you guys will really get it humming for the 8.0 plugin


Comment actions Permalink


Thanks for new idea, our team will discuss it. I'm not sure that it is a good decision because your code should work not only in IDE but also from command line or some other build tools. I consider patching RUBYLIB as a dangerous hack that can affect other source code.
One of our user suggested another idea - we can create general project structure for ruby application with spec and unit tests. In such stubs we can create spec_helper.rb and tests_helper.rb files with correct load paths.

Comment actions Permalink


I agree that using RUBYLIB is not wise, although what textmate does is allow you to "scope" the value of RUBYLIB on a per project basis. I eventually just went with adding it as a module library.

I run my tests from the command line with this script:
ruby -Ilib spec/*_spec.rb

the -Ilib puts the lib directory in the sourcepath of the ruby interpreter, and I don't need any extra ugly requires in the top of my spec files.

Really, the behavior that I think is the most intuitive and what I had expected having used IDEA in the past is for it to handle ruby sources the way it handles java module sources. If a file is part of the module source(i.e. in the src/ directory), then it's visible to other classes that may want to import it, and the classes it yields are included in the classpath of the module's runtime profiles. In other words it's automagically on your classpath.

I think the same should be true of a ruby module. If it's in one of your sourcepath's (lib/ by default), then it should be included (via -I) in the default run profile.

Comment actions Permalink

Ok, it sounds reasonable. I've create issue for it -

Edited by: Roman.Chernyatchik on Oct 21, 2008 10:44 PM


Please sign in to leave a comment.