RubyMine, Spork, RSpec, Cucumber

I can’t take credit for this one; that goes to Ben Lindsey. But since the answer I needed was buried in a comment, I thought I’d give it a little more googleability.

RubyMine needs to load special test formatters for its built-in RSpec and Cucumber runners to work. You can easily configure it to talk to a Spork server when running tests, but you’ll get a LoadError (“no such file to load — teamcity/spec/runner/formatter/teamcity/formatter”) with a vanilla Spork setup because the server won’t be able to find the RubyMine formatter libraries.

The solution is to add the requisite paths in the Spork prefork block. Here’s mine:

 

Spork.prefork do
  if ENV["RUBYMINE_HOME"]
    $:.unshift(File.expand_path("rb/testing/patch/common", ENV["RUBYMINE_HOME"]))
    $:.unshift(File.expand_path("rb/testing/patch/bdd", ENV["RUBYMINE_HOME"]))
  end

  # ...
end

I’ve put the above code in my spec_helper.rb as well as my Cucumber env.rb file. RUBYMINE_HOME is an environment variable I’ve set in my .zshenv file.

This entry was posted in Howto. Bookmark the permalink.
  • http://twitter.com/rgoytacaz Rodrigo Dellacqua

    Or you can go to tools -> Start Spork Server and it will take care of that for you.

    • http://avdi.org Avdi Grimm

      Handy, thanks! However, I’m running Spork under Guard, so that doesn’t help me.

  • http://twitter.com/ylluminate ylluminate

    Hey, thanks for this note. I’d seen it where you saw it originally, however this is a little more clear seeing it extracted.

    Curious on something. I’m quite new and I’d like to run guard-spork + guard-rspec. Right now I’m getting some strangeness when changing my routes.rb on a small sample project from railstutorial.org. It appears that when you change routes.rb in my current setup such that it should fail with 2 matches and 1 failure, it will say that there are no matches and thus no failures. Any ideas?

  • Ricardo Keigo Andrade

    Still valid on RubyMine 5.4 for Guard users. Thanks for keeping the information available.