Is it impossible to use Guard with RubyMine?

前端 未结 5 1238
[愿得一人]
[愿得一人] 2021-01-29 21:07

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

5条回答
  •  萌比男神i
    2021-01-29 21:24

    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:

    Add new run configuration

    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.

    Configure the run configuration

    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.

    Run with bundle exec

    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:

    Guard in Action

    Enjoy!

提交回复
热议问题