gpt4 book ai didi

ruby-on-rails-3 - Guard w/RSpec2、Ruby1.9.3、Rails 3.1.3

转载 作者:行者123 更新时间:2023-12-03 01:44:29 25 4
gpt4 key购买 nike

我正在成功运行 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

如果我修改规范文件,我会在终端和弹出通知中收到有关测试结果的警报。如果我修改 Controller 文件,测试再次正常运行。然而,当我修改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

最佳答案

检查您的spec 目录。它应该有一个用于路由规范的 routing 子目录。如果没有,就创建一个空的。显然,运行 rails g rspec:install 时,RSpec 不会在 spec 下创建任何子目录,但 Guard 希望它在那里。

关于ruby-on-rails-3 - Guard w/RSpec2、Ruby1.9.3、Rails 3.1.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8903875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com