RubyMine 不能使用 Guard 吗? [英] Is it impossible to use Guard with RubyMine?

查看:41
本文介绍了RubyMine 不能使用 Guard 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些莫名其妙的原因,RubyMine 会自动保存您所做的每一次更改,因此每次击键都会触发 Guard 运行您的测试!最可笑的是,显然无法禁用此自动保存功能".我只是想知道,RubyMine 似乎是 Rails 开发人员中非常流行的编辑器,而 Guard 似乎是用于自动化测试的不可或缺的工具.既然 Guard 不可能与 RubyMine 一起合理使用,那么人们如何使用 RubyMine 处理自动化测试呢?

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?

推荐答案

我整天都在使用 RubyMine 和 Guard,事实上,Guard 的某些部分已经在 RubyMine 中自己开发了.

Im using RubyMine with Guard all day, and in fact, some parts of Guard have been developed in RubyMine itself.

您可以通过转到 RubyMine > 来配置自动安全行为.菜单中的首选项并在搜索框中输入sync,然后从列表中选择System Settings.

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.

图片显示了我的设置,这些工作正常.您可能还想禁用 Save files on frame deactivation,以便仅在手动保存时保存文件.

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.

我更喜欢从终端使用 Guard,但您可以通过选择 Run > 添加 运行配置 来配置 RubyMine 以直接运行 Guard.从菜单编辑配置:

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:

现在您可以通过单击加号 + 并选择 IRB 控制台 来添加新配置:

Now you can add a new configuration by clicking on the plus sign + and select IRB console:

现在将配置命名为Guard,在IRB脚本中输入Guard的路径并设置项目工作目录.您可能希望将 Guard 参数作为 IRB 参数输入,例如不同的 Guard 组等.

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.

我通过打开终端找到我的Guard路径,切换到项目工作目录并输入which guard,结果是/Users/michi/.rvm/gems/ruby-1.9.3-p194/bin/guard 用于我的 Ruby 1.9.3-p194 SDK,由 RVM 管理.

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.

接下来,您需要在 Bundler 选项卡中检查 Run the script in the context of the bundle.

Next you need to check the Run the script in context of the bundle in the Bundler tab.

现在按OK,你就有了一个全新的运行配置.在启动 Guard 之前,您应该通过添加

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

到您的Guardfile.现在您可以直接在 RubyMine 中运行(甚至调试)Guard:

to your Guardfile. Now you can run (or even debug) Guard directly within RubyMine:

享受吧!

这篇关于RubyMine 不能使用 Guard 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆