Project Help with Lib & Test folders

I would like to use RubyMine on some projects but I can't figure out how to use it with even the simplest project. I have put up a small repro at https://github.com/cgorshing/RubyMineTrial, the problem I am having is with my tests.

I typically run these tests by using rake test, but I would like to get them working with RubyMine's test runner. The error I always get is "in `require': no such file to load -- project_name/part (LoadError)". I've played around with RubyMine's load path and I have set the test directory as test sources, but I still come up short. I'm trying to follow the layout as described at http://cookingandcoding.com/2009/06/04/creating-a-ruby-gem/

Any suggestions?

1 comment
Comment actions Permalink

Hello Chad,

Thank you for the sample project, I've just taken a look on it.

There is still to ways for launching tests.

1. Using rake
2. Directly launch test, without rake

How to configure:
for "1":
* set some sdk with rake gem as project SDK (e.g. I have ruby-1.8.7-p249 rvm sdk). See "File | Settings | Ruby SDK and Gems | Ruby interpreter" combobox
* Tools | Run Rake Task... & select "test" rake task
Screen shot 2010-12-22 at 3.02.45 PM.png

for "2":
At first RubyMine doesn't tweak load path of your application (loadPath settings is only for RubyMine code analyze features), thus you  need manually add "lib" folder to tests load path. There are a lot of ways to do this.

* E.g. set your project root as working directory and add "-Ilib" to ruby interpreter options in you run configuration settings:
Screen shot 2010-12-22 at 3.06.28 PM.png
Optionally you may save tweaked working directory and ruby args in default Test::Unit/Shoulda project run configuration settings.

Or more general and correct way:
* create "test/test_helper.rb" file with content

$: <<  File.dirname(__FILE__) + "/../lib"

require 'test/unit'

* in "test_signature.rb" replace 'require test/unit' with require 'test_helper'

#!/usr/bin/env ruby -w

require 'test_helper'
require 'project_name/part'

class TestProjectName < Test::Unit::TestCase

.....

Now it will work in console & rubymine without additional run configuration settings tweaking.

0

Please sign in to leave a comment.