Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Running tests with Zeus in RubyMine

(Adapted from a thread on the RubyMine support forums)

Zeus is a self-described “language-agnostic application checkpointer for non-multithreaded applications.” As a Rails developer, you can use Zeus to keep your rails environment loaded so your tests run super fast. Spork does this job as well, but Zeus is newer/shinier and requires less explicit configuration. Zeus’ standard operating mode requires you to keep a Zeus server running (started with zeus start) to which you can issue commands (like zeus rspec).

To get Zeus installed on your system, follow the readme or this lovely post at ThoughtBot. The issue they mention with require ‘rspec/autorun’ should be fixed in the latest Zeus, but you can safely remove it from your spec_helper anyway.

In your Gemfile, add zeus:

group :test do
  gem 'zeus'

Yes the Zeus manual wants you to only have one global install, but RubyMine won’t be able to see it when running tests, because it always runs them under bundler. (You’ll get a cannot load such file — zeus or zeus is not part of the bundle error.)

Add this script to your Rails project as script/rspec_runner.rb:

#!/usr/bin/env ruby

# Suppress zeus' whining about how it won't use your RAILS_ENV

# Zeus 0.13.2 parses options badly. RubyMine will invoke this file like this:
# rspec_runner.rb spec/my_cool_file.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter
# ...but Zeus will parse those options thinking --require is meant for it, and die.
# If the test file is moved to the end, it dies less.

# Add rspec to the beginning of the commands sent to Zeus
ARGV.unshift 'rspec'

require 'rubygems'
require 'zeus'
load Gem.bin_path('zeus', 'zeus')

In RubyMine’s ‘Edit Configurations’, under Default -> Rspec:

Check ‘Use Custom Rspec Runner Script’
Set it to [your-absolute-app-path]/script/rspec_runner.rb

Your ‘Edit Configuration’ window should look like this: zeus_setup

When starting the Zeus server, use the following line:

env RUBYLIB=/Applications/ zeus start

(I made this a script in my project called script/startzeus.)

These directories are where RubyMine keeps its favorite test formatters, and if you don’t tell Zeus about them at server load time, it may never find them. (you’ll get a cannot load such file — teamcity/spec/runner/formatter/teamcity/formatter error). If you’re not on OSX, you should replace these directories with something relevant to your system.

Now you can run a test in RubyMine just like you would normally, and it should be LIGHTNING FAST. Get it? Lightning? Zeus? You get it.

  1. Sebastian says:

    Thanks for the clear instructions, I was looking for exactly this.

  2. Julie says:

    Have you been able to get the Rubymine debugger to work with zeus? I can get the tests to run using your example above and another approach, but the RubyMine debugger appears to be entirely skipped. I have the debugger working properly with my rspec tests without zeus.

  3. This mixed with auto-rerun must be fantastic.

  4. Ole says:

    Same as @Julie, I’m using this and loving it, but I can’t get it working with the debugger, it’s simply not breaking. Does this work for you? Thanks!

  5. Brian Butz says:

    I really like how fast Zeus makes my test suite, but be wary that it basically ignores the concept of requiring files. You can remove the ‘require “spec_helper”‘ line from the top of your file and Zeus will still run the test just fine, although it will obviously not run on CI.

  6. Hey great article, thanls!

    The shell script unfortenately only works for single files, if I do `run all specs in spec` (with the same default run config) i get the following error:

    zeusclient.go:86: EOF
    /Users/erotte/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner’: Command failed with status (1): [/Users/erotte/.rbenv/versions/2.0.0-p0/bin…] (RuntimeError)
    from /Users/erotte/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call’
    from /Users/erotte/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh’
    from /Users/erotte/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh’
    from /Applications/ `’
    from -e:1:in `load’
    from -e:1:in `’
    I didn’t get any further information sorry.
    Any ideas about that?

  7. Joe S says:

    Doesn’t work – I get this error: “Unable to attach test reporter to test framework or test framework quit unexpectedly”.

    No stack trace. Just this message in red. any idea?

  8. Tim Booher says:

    I get the same error as Joe S . . . but with:

    0 files were found.
    RSpec script : /Users/tim/Sites/polco3/script/rspec_runner.rb

    Spec Options:
    Running specs…
    Command line:
    [“/Users/tim/.rvm/rubies/ruby-1.9.3-p392/bin/ruby”, “-e”, “$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)”, “/Users/tim/Sites/polco3/script/rspec_runner.rb”, “–require”, “teamcity/spec/runner/formatter/teamcity/formatter”, “–format”, “Spec::Runner::Formatter::TeamcityFormatter”]
    Can’t connect to master. Run zeus start first.
    /Users/tim/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/file_utils.rb:53:in `block in create_shell_runner’: Command failed with status (1): [/Users/tim/.rvm/rubies/ruby-1.9.3-p392/bin…] (RuntimeError)
    from /Users/tim/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call’
    from /Users/tim/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `sh’
    from /Users/tim/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `sh’
    from /Applications/ `’
    from -e:1:in `load’
    from -e:1:in `’

    Process finished with exit code 1

  9. […] that and we’re off to the fun parts.  I started off following this post from pivotallabs:  I’m going to recap it here so it’s all in one […]

  10. Clark Rasmussen says:

    Thanks, I found this extremely useful.

    When testing multiple files, RubyMine lists the spec files at the end of the command line. I fixed the script by changing:



    ARGV.push(ARGV.shift) unless ARGV[-1].match(/.rb$/)

    Also, I run zsh, and I had to change the Zeus server invocation to this:

    $ export RUBYLIB=…
    $ zeus start

    I’m not sure why “env RUBYLIB= … zeus start” form didn’t work.

  11. Danil says:

    I’m wondering how to make same for cucumber…

  12. Andrew Brown says:

    Just wanted to suggest offfer this variant, that runs even if zeus is not running:

    if system(%q{zeus r “;”})

    load Gem.bin_path(‘zeus’, ‘zeus’)

  13. Andrew Pietsch says:

    zeus 0.13.4.pre2 works for me without the custom spec runner. Found the details here:


Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *