本文介绍了在 Windows 上使用 Guard 和 rspec 更改文件时不会运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了用于我的 rails 应用程序的 guard-rspec gem.当我通过 bundle exec guard 从命令行启动 guard 时,它第一次运行我的整个测试套件没有问题.

I've installed the guard-rspec gem for use in my rails application. When I start up guard from the command line via bundle exec guard, it runs my entire test suite the first time with no problem.

但是,每当我对规范文件或我的 Guardfile 中指定的任何监视文件进行任何更改时,Guard 似乎都无法识别这些更改,并且不会重新运行任何测试.

However, any time I make any changes to a spec file or any watched files as specified in my Guardfile, Guard doesn't seem to recognize the changes and no tests are rerun.

我什至尝试像这样在我的 Guardfile 中放置一些明确的内容:

I even tried putting something every explicit in my Guardfile like this:

watch("app/views/orders/new.html.erb")          { "spec/requests/orders_spec.rb" }

当我编辑和保存 new.html.erb 时,哪个应该触发我的 orders_spec.rb 测试运行?好吧,当我编辑它并点击保存时,没有任何反应,甚至没有错误或警告.

which should trigger my orders_spec.rb test to run when I edit and save new.html.erb correct? Well, when I edit it and hit save, nothing happens, not even an error or a warning.

有没有人在 Windows 上运行过 Guard 或遇到过类似的问题?

Has anyone had any luck running Guard on windows or encountered a similar problem?

推荐答案

我不是 Windows 用户,这不是我的个人经验,但作为 Guard 维护者,我经常听到 fchange gem 有它的问题.您可以强制 Guard 轮询更改,从而跳过 fchange:

I'm not a Windows user and this is not from my personal experience, but as a Guard maintainer I often hear that the fchange gem has its problems. You can force Guard polling for changes and thus skip fchange with:

捆绑执行保护 -p

Maher Sallam 已经解决了这个问题并创建了 wdm,这似乎更可靠.还有一个拉取请求,用于将其集成到 Guard 中.我建议你测试集成并从真实世界的 Windows 用户那里给 Maher 一些反馈,因为 Maher 是一个 Linux 人 :P

Maher Sallam has addressed this issue and created wdm, which seems to be more reliable. There's also a pull request for integrate it into Guard. I recommend you to test the integration and give Maher some feedback from a real world Windows user, since Maher is a Linux guy :P

这篇关于在 Windows 上使用 Guard 和 rspec 更改文件时不会运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 12:10