-
Notifications
You must be signed in to change notification settings - Fork 0
Step11: Optimizing Rails Commands and Test Runners
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
-
Install zeus by running
$ gem install zeusand then run$ zeus startand open up a new terminal window to start running zeus commands (i.e.$ zeus generate controller...instead ofrails 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.rc2followed by$ zeus initfollowed by$ zeus start. -
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. -
Live Reloading of Browser: Add
gem 'guard-livereload'to your Gemfile, run bundler, and then run$ guard init livereloadto 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.
-
Add
gem "parallel_tests"andgem "zeus-parallel_tests"to the test and development block in your Gemfile and run bundle install. -
Add an environment variable specifying the number of cores to be used in your application.yml file,
TEST_ENV_NUMBER: 4, for example. Inconfig/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'] %> ```
-
Run
$ rake parallel:createfollowed by$ rake parallel:prepare. If your using Postgres you may have to run rake db:test:prepare again to get all of this working. -
Run
$ zeus-parallel_tests initand overwrite your currentcustom_plan.rbandzeus.jsonfiles, then restart zeus (zeus start) and you should be ready to run your tests in parallel with$ zeus parallel_rspec spec