Guard w/ RSpec2、Ruby1.9.3、Rails 3.1.3
我正在成功运行 Guard,并收到 Libnotify 提供的通知。
funkdified@funkdified-laptop:~/railsprojects/sample_app$ guard
Guard uses Libnotify to send notifications.
Guard is now watching at '/home/funkdified/railsprojects/sample_app'
Guard::RSpec is running, with RSpec 2!
Running all specs
...
Finished in 0.06053 seconds
3 examples, 0 failures
如果我修改规范文件,我会在终端和弹出通知中收到有关测试结果的警报。如果我修改控制器文件,测试再次正常运行。然而,当我修改routes.rb时,一切都崩溃了,Guard停止正常工作并抛出错误。有人有什么想法吗?
错误:
Running: spec/routing
/home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load': cannot load such file -- /home/funkdified/railsprojects/sample_app/spec/routing (LoadError)
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun
忘记提及,如果我杀死 Guard 并重新启动(在对 paths.rb 进行更改后),则 Guard 再次正常执行,表明测试现已失败:
funkdified@funkdified-laptop:~/railsprojects/sample_app$ guard
Guard uses Libnotify to send notifications.
Guard is now watching at '/home/funkdified/railsprojects/sample_app'
Guard::RSpec is running, with RSpec 2!
Running all specs
..F
Failures:
1) PagesController GET 'about' returns http success
Failure/Error: get 'about'
ActionController::RoutingError:
No route matches {:controller=>"pages", :action=>"about"}
# ./spec/controllers/pages_controller_spec.rb:22:in `block (3 levels) in <top (required)>'
Finished in 0.0576 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' returns http success
I am running Guard successfully with notifications provided by Libnotify.
funkdified@funkdified-laptop:~/railsprojects/sample_app$ guard
Guard uses Libnotify to send notifications.
Guard is now watching at '/home/funkdified/railsprojects/sample_app'
Guard::RSpec is running, with RSpec 2!
Running all specs
...
Finished in 0.06053 seconds
3 examples, 0 failures
If I modify the spec file I am alerted as to the results of the test, both in the terminal and with a popup notification. If I modify a controller file, again tests run normally. However, when I modify routes.rb, the whole things falls on its face and Guard stops working normally and throws up an error. Anyone have any ideas?
Error:
Running: spec/routing
/home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load': cannot load such file -- /home/funkdified/railsprojects/sample_app/spec/routing (LoadError)
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun
Forgot to mention, if I kill Guard and restart (after making changes to routes.rb) then Guard again performs normally, suggesting that a test has now failed:
funkdified@funkdified-laptop:~/railsprojects/sample_app$ guard
Guard uses Libnotify to send notifications.
Guard is now watching at '/home/funkdified/railsprojects/sample_app'
Guard::RSpec is running, with RSpec 2!
Running all specs
..F
Failures:
1) PagesController GET 'about' returns http success
Failure/Error: get 'about'
ActionController::RoutingError:
No route matches {:controller=>"pages", :action=>"about"}
# ./spec/controllers/pages_controller_spec.rb:22:in `block (3 levels) in <top (required)>'
Finished in 0.0576 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' returns http success
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您的
spec
目录。它应该有一个用于路由规范的routing
子目录。如果没有,就创建一个空的。显然,当运行rails g rspec:install
时,RSpec 不会在spec
下创建任何子目录,但 Guard 希望它在那里。Check your
spec
directory. It should have arouting
sub-directory for routing specs. If not, just create an empty one. Apparently, RSpec does not create any sub-directories underspec
when runningrails g rspec:install
, but guard expects it to be there.我认为您的
Guardfile
中可能有以下行:如果
spec/routing
中没有规范,则不要文件夹不需要的内容。将该行更改为:现在,当您更新
routes.rb
文件时,您的所有规范都将运行。I think you may have the following line in your
Guardfile
:If you don't have specs in
spec/routing
, then don't folder that you don't need. Change the line to:Now, all your specs will run when you update your
routes.rb
file.