如何在 MacVim 中运行 Ruby 规范和/或测试而不锁定 MacVim?

发布于 2024-09-26 08:49:33 字数 900 浏览 1 评论 0 原文

大约 6 个月前,我从 TextMate 切换到 MacVim 来完成我的所有开发工作,其中主要包括使用 Ruby、Ruby on Rails 和 JavaScript 进行编码。

使用 TextMate,每当我需要运行规范或测试时,我只需在测试或规范文件上使用 Command+R,就会打开另一个窗口,并且会以应用的“漂亮”格式显示结果。如果规范或测试很长,我可以继续使用代码库,因为测试/规范是在单独的进程/窗口中运行的。测试运行后,我可以直接单击结果到规范文件中的相应行。

Tim Pope 出色的rails.vim 插件非常接近在MacVim 环境中模拟这种行为。运行 :Rake 当当前缓冲区是测试或规范时运行文件,然后拆分缓冲区以显示结果。您可以浏览结果并键入文件中的相应位置。

Rails.vim 方法的问题是它会在测试运行时锁定 MacVim 窗口。对于大型应用程序来说,这可能是一个问题,因为这些应用程序可能在测试中内置了大量设置/拆卸。另外,TextMate 显示的视觉红/绿 html 结果(我假设是通过 --format Pretty)比分割窗口更容易扫描。

这家伙大约 18 个月前就接近了:http://cassiomarques.wordpress.com/2009/01/09/running-rspec-files-from-vim-showing-the-results-in-firefox/ 他的脚本已经进行了一些黑客攻击,但测试仍然在 MacVim 中运行并锁定了当前窗口。

关于如何在 MacVim 中完全复制上述 TextMate 行为有什么想法吗?

谢谢!

About 6 months ago I switched from TextMate to MacVim for all of my development work, which primarily consists of coding in Ruby, Ruby on Rails and JavaScript.

With TextMate, whenever I needed to run a spec or a test, I could just command+R on the test or spec file and another window would open and the results would be displayed with the 'pretty' format applied. If the spec or test was a lengthy one, I could just continue working with the codebase since the test/spec was running in a separate process/window. After the test ran, I could click through the results directly to the corresponding line in the spec file.

Tim Pope's excellent rails.vim plugin comes very close to emulating this behavior within the MacVim environment. Running :Rake when the current buffer is a test or spec runs the file then splits the buffer to display the results. You can navigate through the results and key through to the corresponding spot in the file.

The problem with the rails.vim approach is that it locks up the MacVim window while the test runs. This can be an issue with big apps that might have a lot of setup/teardown built into the tests. Also, the visual red/green html results that TextMate displays (via --format pretty, I'm assuming) is a bit easier to scan than the split window.

This guy came close about 18 mos ago: http://cassiomarques.wordpress.com/2009/01/09/running-rspec-files-from-vim-showing-the-results-in-firefox/ The script he has worked with a bit of hacking, but the tests still ran within MacVim and locked up the current window.

Any ideas on how to fully replicate the TextMate behavior described above in MacVim?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枕梦 2024-10-03 08:49:33

有一个名为 vim-addon-background-cmd 的插件可以允许您可以在后台运行任务,而不是锁定 vim 界面。您必须创建调用才能运行后台命令。请参阅 文档有关如何执行此操作的更多信息。

There is a plugin called vim-addon-background-cmd that can allow you to run tasks in the background instead of locking up the vim interface. You would have to create the call to run through the background command. See the docs for more information on how to do that.

柠檬心 2024-10-03 08:49:33

几个月前,我一直在寻找同样的东西。然后我发现了 rspec 的自动测试。现在,我打开一个单独的终端窗口,其中显示我上次运行的测试。如果我更改任何相关代码文件,我的测试将自动为我运行(监视文件,如果它们更改,则运行测试)。

如果您希望在非 Rails 项目中具有相同的自动测试类型行为,您可以查看 watchr gem。它的功能类似于自动测试,但您可以在任何框架中使用它。

A few months back I was looking for this same exact thing. Then I discovered autotest with rspec. Now I keep a separate terminal window open which shows my last run tests. If I change any relavent code files my tests are automatically run for me (the files are watched and if they change the tests run).

If you want the same autotest type behavior in a non-rails project you can look at the watchr gem. It's functionality is similar to autotest but you can use it in ANY framework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文