Skip to content

Step11: Optimizing Rails Commands and Test Runners

Lev Brie edited this page Jul 30, 2013 · 6 revisions

Note: You should already have guard installed, along with rb-fsevent, which it depends on, if you're on a Mac. You should have also already run $ bundle binstubs rspec-core

  1. Install zeus by running $ gem install zeus and then run $ zeus start and open up a new terminal window to start running zeus commands (i.e. $ zeus generate controller... instead of rails generate controller.... If you have any problems, please refer directly to the Zeus documentation as things can get a little bit tricky in terms of backported garbage collection, etc., and there's not much of a point in reproducing the documentation here. In my case, I needed to try quite a few different configurations to get it working, although eventually the following worked for me: $ gem install zeus -v 0.13.3.rc2 followed by $ zeus init followed by $ zeus start.

  2. You should already have guard and guard-rspec installed and should have already run $ guard init rspec. If you're feeling adventurous, inside of your Guardfile, alter your rspec initializer to read $ guard :rspec, :zeus => true do # enable zeus support; default: false. Start up Guard in a separate window by running $ guard. I recommend against this, however, because zeus is quite buggy and will often cause tests to fail that ought to pass, at least in my experience.

  3. Live Reloading of Browser: Add gem 'guard-livereload' to your Gemfile, run bundler, and then run $ guard init livereload to add guard-livereload to your Guardfile. Restart Guard. Add the livereload extensions to your browsers: Chrome; Safari (this may not work with local files); Firefox.

TODO: Installing parallel testing did not work for me with postgres test databases.

  1. Add gem "parallel_tests" and gem "zeus-parallel_tests" to the test and development block in your Gemfile and run bundle install.

  2. Add an environment variable specifying the number of cores to be used in your application.yml file, TEST_ENV_NUMBER: 4, for example. In config/database.yml, add this test env variable to your test database like so:

test: adapter: postgresql encoding: unicode database: rangular_test<%= ENV['TEST_ENV_NUMBER'] %> ```

  1. Run $ rake parallel:create followed by $ rake parallel:prepare. If your using Postgres you may have to run rake db:test:prepare again to get all of this working.

  2. Run $ zeus-parallel_tests init and overwrite your current custom_plan.rb and zeus.json files, then restart zeus (zeus start) and you should be ready to run your tests in parallel with $ zeus parallel_rspec spec

Clone this wiki locally