Tests do not run when file changes with Guard and rspec on windows

隐身守侯 提交于 2020-01-10 04:54:08

问题


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.

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.

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

watch("app/views/orders/new.html.erb")          { "spec/requests/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.

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


回答1:


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:

bundle exec guard -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




回答2:


I had this issue (but on a Mac). I had a spec for a service class, and when I saved the spec the tests ran in guard, but when I saved the service class the corresponding spec did not run. Only this class was affected. Turns out my spec's filename had a typo in it and didn't match the name of the class's filename. If your spec isn't running on save, make sure your filenames are correct.



来源:https://stackoverflow.com/questions/11766511/tests-do-not-run-when-file-changes-with-guard-and-rspec-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!