5

在 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的要点链接

4

2 回答 2

10

你应该改变:

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 
于 2012-05-10T04:20:40.700 回答
5

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

解决方案是增加等待时间:wait => 120Guardfile例如

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, 
               :rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 120
    ....
于 2011-10-29T13:26:01.923 回答