【问题标题】:Guard crashing Spork when using guard-spork使用guard-spork时Guard crashing Spork
【发布时间】:2011-12-11 19:35:03
【问题描述】:

我关注了"How I Test" screencast at 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,它就可以正常工作。 Here's link to gist 与我的 Gemfile、Guardfile 和 spec_helper.rb

【问题讨论】:

    标签: ruby rspec spork guard


    【解决方案1】:

    你应该改变:

    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 
    

    【讨论】:

    • taivn07 和 Kevin Bedell 的解决方案对我来说比 Jakub 的解决方案效果更好。增加等待时间并不能解决问题。禁用 Cucumber 和 TestUnit 解决了它。
    • 要在没有 rspec 的情况下使用 minitest,请将 :rspec_env 位更改为 :rspec => false 并添加 :minitest_env => { 'RAILS_ENV' => 'test' }
    【解决方案2】:

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

    解决办法是在Guardfile中用:wait => 120增加等待时间,例如

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-24
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多