Search code examples
rubyrspecrubymine

RubyMine IDE Cannot Find Spec Files in Spec directory


I have loaded a Ruby project into RubyMine, that has it's spec files located in a spec directory, as usual. Right-clicking and selecting 'run' on any single spec file correctly runs it. Right-clicking and selecting 'run all' on the specs directory causes every test to fail with the following message:

Fail to load: /Users/nathaniel/repos/close-web/spec/compositions/analysis/analysis_data_spec.rb:1 Exception message: cannot load such file -- spec_helper

Inside the launch configuration, the 'Tests folder' seems to be set correctly:

/Users/nathaniel/repos/close-web/spec

And the working directory as well:

/Users/nathaniel/repos/close-web

The Ruby arguments are set like this:

-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest

(There is some indication on the RubyMine website that -Itest is required.) Under the Bundler tab 'Run the script in the context of the bundle' is checked as well. I'm unclear what else RubyMine might need to be able to recursively find and execute the tests. Running them from the command line works fine:

~repos/closeweb $ bundle exec rspec spec
... (all the tests running)

Finished in 6 minutes 27 seconds (files took 13.39 seconds to load)
1054 examples, 0 failures, 108 pending

What configuration is wrong here that all the tests won't run?


Solution

  • Given that your folder is called spec, not test, you need to -Ispec, not -Itest.

    In other words, your RubyMine arguments should be:

    -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Ispec
    

    From the ruby man page:

    -I directory   Used to tell Ruby where to load the library scripts.
                   Directory path will be added to the load-path variable ($:)