【问题标题】:Why are my specs while using Guard so slow?为什么我在使用 Guard 时的规格如此缓慢?
【发布时间】:2011-12-17 20:33:11
【问题描述】:

当我只使用 spork 运行我的规范时,我的性能得到了相当大的提升

$ time rspec .
.....

Finished in 11.39 seconds
5 examples, 0 failures

real    0m11.780s
user    0m10.318s
sys     0m1.180s

还有叉子

$ time rspec . --drb
.....

Finished in 107.24 seconds
5 examples, 0 failures

real    0m1.968s
user    0m0.488s
sys     0m0.095s

真是太棒了。但是一旦我投入了防守,似乎一切都变得如此缓慢,好像根本没有spork。

$ guard
Guard is now watching at '/Users/darth/projects/scvrush'
Starting Spork for RSpec 
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
Running all specs
.....

Finished in 10.77 seconds
5 examples, 0 failures

即使我不看Finished in 10.77 seconds,我每次尝试运行规范时至少可以数 6-8 秒,即使只是一个模型。

我做了一些minor edits to the Guardfile,例如:wait => 120,但这应该只影响guard启动时。

【问题讨论】:

  • 我从来没有使用过Guard,但是你在使用Guard 的时候在哪里传递--drb?您是否已将--drb 添加到您的.rspec 文件中?
  • @d11wtq 有一个 guard-spork gem,它告诉 Guard 启动一个 spork 实例,然后是它的所有规格,所以它应该开箱即用......或者我错过了某事

标签: ruby testing rspec automated-tests guard


【解决方案1】:

您必须在 Guardfile 中为 rspec 传递 --drb 选项,如下所示:

guard 'rspec', :version => 2, :cli => '--drb' do
 ...
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-03
    • 2015-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-28
    • 2023-03-31
    • 2016-03-27
    相关资源
    最近更新 更多