使用 Guard-Spork 时 Guard 会导致 Spork 崩溃

发布于 2024-12-11 04:12:25 字数 1544 浏览 2 评论 0原文

我已经关注了 RailsCasts 上的“我如何测试”截屏视频,但是我遇到了spork 的问题

$ guard
Guard is now watching at '/Users/darth/projects/auth-before'
Starting Spork for Test::Unit & RSpec 
Couldn't find a supported test framework that begins with 'testunit'

Supported test frameworks:
( ) Cucumber
(*) RSpec

Legend: ( ) - not detected in project   (*) - detected
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
ERROR: Could not start Spork server for Test::Unit & RSpec. Make sure you can use it manually first.

# here I get growl notification "Test::Unit & RSpec NOT started

Guard::RSpec is running, with RSpec 2!
Running all specs
Running tests with args ["--color", "--format", "progress", "--format", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "--require", "/Users/darth/.rvm/gems/ruby-1.9.2-p290/gems/guard-rspec-0.5.0/lib/guard/rspec/formatters/notification_rspec.rb", "spec"]...
.

Finished in 14.47 seconds
1 example, 0 failures
Done.

当我尝试在单独的终端窗口中运行 spork 时,它没有帮助,因为一旦我运行 guard 它就会立即被杀死

$ spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Killed: 9

如果我就跑spork 然后尝试 rspec 。 --drb,它工作得很好。 这是要点链接以及我的 Gemfile、Guardfile 和 spec_helper.rb

I've followd the "How I Test" screencast at RailsCasts, however I ran into a problem with spork

$ guard
Guard is now watching at '/Users/darth/projects/auth-before'
Starting Spork for Test::Unit & RSpec 
Couldn't find a supported test framework that begins with 'testunit'

Supported test frameworks:
( ) Cucumber
(*) RSpec

Legend: ( ) - not detected in project   (*) - detected
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
ERROR: Could not start Spork server for Test::Unit & RSpec. Make sure you can use it manually first.

# here I get growl notification "Test::Unit & RSpec NOT started

Guard::RSpec is running, with RSpec 2!
Running all specs
Running tests with args ["--color", "--format", "progress", "--format", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "--require", "/Users/darth/.rvm/gems/ruby-1.9.2-p290/gems/guard-rspec-0.5.0/lib/guard/rspec/formatters/notification_rspec.rb", "spec"]...
.

Finished in 14.47 seconds
1 example, 0 failures
Done.

When I try to run spork in a separate terminal window, it doesn't help, as it gets killed instantly once I run guard

$ spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Killed: 9

If I just run spork and then try rspec . --drb, it works just fine. Here's link to gist with my Gemfile, Guardfile and spec_helper.rb

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

寒江雪… 2024-12-18 04:12:25

您应该将:更改

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, 
               :rspec_env => { 'RAILS_ENV' => 'test' }, 
               :wait => 120

为:

guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, 
                cucumber: false, 
                test_unit: false 

You should change:

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, 
               :rspec_env => { 'RAILS_ENV' => 'test' }, 
               :wait => 120

to:

guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, 
                cucumber: false, 
                test_unit: false 
安穩 2024-12-18 04:12:25

这个问题实际上是由 guard 在加载之前杀死 spork 造成的,这是我的较慢 MacBook pro 上的问题。

解决方案是通过 :wait => 增加等待时间Guardfile 中的 120,例如

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, 
               :rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 120
    ....

This problem is actually caused by guard killing spork before it can even load, which is a problem on my slower MacBook pro.

The solution is to increase the wait time with :wait => 120 in the Guardfile, e.g.

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