Guard w/ RSpec2、Ruby1.9.3、Rails 3.1.3

发布于 2024-12-27 16:36:05 字数 2519 浏览 1 评论 0原文

我正在成功运行 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 技术交流群。

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

发布评论

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

评论(2

爱的故事 2025-01-03 16:36:05

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

Check your spec directory. It should have a routing sub-directory for routing specs. If not, just create an empty one. Apparently, RSpec does not create any sub-directories under spec when running rails g rspec:install, but guard expects it to be there.

微暖i 2025-01-03 16:36:05

我认为您的 Guardfile 中可能有以下行:

watch('config/routes.rb')                           { "spec/routing" }

如果 spec/routing 中没有规范,则不要文件夹不需要的内容。将该行更改为:

watch('config/routes.rb')                           { "spec" }

现在,当您更新 routes.rb 文件时,您的所有规范都将运行。

I think you may have the following line in your Guardfile:

watch('config/routes.rb')                           { "spec/routing" }

If you don't have specs in spec/routing, then don't folder that you don't need. Change the line to:

watch('config/routes.rb')                           { "spec" }

Now, all your specs will run when you update your routes.rb file.

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