25

我关注了spork railscast 视频,当我尝试运行警卫时,它给了我以下错误:

Guard is now watching at '/Users/m/work/'
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.
Guard::RSpec is running, with RSpec 2!
Running all specs

看起来 spork 服务器启动正常,然后出错并尝试继续。我尝试将 :wait 选项设置为 120 秒,但仍然存在相同的问题。

如果我在没有 guard & guard-spork 的情况下执行测试,Spork 工作正常

环境:

  • Mac OSX
  • 导轨 (3.1.1)
  • 后卫(0.8.8)
  • 后卫-rspec (0.5.4)
  • 叉叉 (0.9.0.rc9)
  • 防护叉 (0.3.1)

我将如何调试这个问题?我不知道从哪里开始。

4

2 回答 2

76

我在 Ubuntu 上遇到了这个问题。我的解决方案很简单:

1)我停止了守卫

2)我删除了测试文件夹

3) 开始守卫

这一次,我没有看到为 Test::Unit & RSpec 启动 Spork,而是为 RSpec 获得了 Starting Spork。所以 spork 自动识别出我的测试文件夹不再需要,一切都运行得很好。

有趣的是

Supported test frameworks:
( ) Cucumber
(*) RSpec

消息也消失了,我得到了完全符合 railscast 的预期结果。

我能得出的唯一结论是:

1)这不是依赖于操作系统的问题。

2) spork、rspec 和 test unit 在 Rails > v3.x 应用程序上表现不佳,这是有道理的。你不需要两者。更新 - 如果您想要两者,请参阅下面的更新答案。

显然,我非常严格地遵循了 Railscast 的说明,但我强烈建议您考虑删除测试文件夹。

更新 应该注意的是,根据@yuvlio 的以下评论,有可能让两者一起玩得很好,其中的引述如下:

我认为问题不在于他们相处不来。我让 Cucumber/Rspec/testunit 在 spork 中相互配合。在我的 gemfile 中,除了 rspec/cucumber/guard 相关的 gems 之外,我还添加了 spork-testunit、guard-test、ruby-prof gems 并运行了 bundle install。然后,我启动了 testunit:bundle exec spork testunit --bootstrap。然后自定义了 test/test_helper.rb。然后更新了监视 testunit 的保护文件:bundle exec guard init test。当我运行警卫时,我得到了输出,包括 RSpec、Cucumber、Test::Unit 的 Spork 服务器成功启动

于 2011-11-26T10:13:26.547 回答
17

如果您不想删除测试文件夹,您可以简单地告诉守卫忽略它:

guard 'spork', test_unit: false do
  # ...
end
于 2012-12-13T14:11:56.590 回答