For some inexplicable reason, RubyMine autosaves every change you make and so every key stroke will trigger Guard to run your tests! And the most ridiculous thing is that there's apparently no way to disable this autosaving "feature". I'm just wondering, RubyMine seems to be a very popular editor among Rails developers and Guard seems to be an indispensable tool used to automate testing. Since Guard is impossible to use reasonably with RubyMine, how do people deal with automating their tests with RubyMine?
Im using RubyMine with Guard all day, and in fact, some parts of Guard have been developed in RubyMine itself.
You can configure the auto-safe behavior by going to RubyMine > Preferences
in the menu and enter sync
in the search box, then select System Settings
from the list.
The picture shows my settings and these works fine. You may also want to disable Save files on frame deactivation
, to only save a file on a manual save.
I prefer to use Guard from the terminal, but you can configure RubyMine to run Guard directly by adding a Run configuration by selecting Run > Edit configurations
from the menu:
Now you can add a new configuration by clicking on the plus sign +
and select IRB console
:
Now name the configuration Guard
, enter the path to Guard into IRB script and set the project working directory. You may want to enter your Guard arguments as IRB arguments, like different Guard groups, etc.
I found my path to Guard by opening the terminal, changed into the project working directory and entered which guard
, which results in /Users/michi/.rvm/gems/ruby-1.9.3-p194/bin/guard
for my Ruby 1.9.3-p194 SDK managed by RVM.
Next you need to check the Run the script in context of the bundle in the Bundler
tab.
Now press OK
and you have a brand new run configuration. Before starting Guard, you should configure the interactor to simple by adding
interactor :simple
to your Guardfile
. Now you can run (or even debug) Guard directly within RubyMine:
Enjoy!