Spork 计时器在运行之间不会重置

发布于 2024-12-10 11:09:58 字数 1127 浏览 1 评论 0原文

这是我在 github 上创建的 问题 的复制+粘贴,但我要问这里也以防万一有人知道如何修复它


使用 spork 0.9.0.rc9,我注意到显示规格运行所需时间的计时器不会在运行之间重置自身,而是输出已累积的总时间自从 spork 服务器启动以来。

重现步骤:

  1. 在另一个窗口中使用命令 spork
  2. 运行 rspec 从控制台启动 spork 。 --drb
  3. 观察到规范需要 X 秒才能运行,并且控制台输出验证此
  4. 等待 60 秒,修改控制器规范,然后重复步骤 2
  5. 观察到规范需要大约 Y 秒才能运行,但控制台输出声称它们花费了 (X + Y + 60) 秒。
  6. 等待 10 分钟,重复步骤 2
  7. 观察规范在 Z 秒内运行,但控制台输出将数字显示为 (X + Y + Z + 600) 秒

我的spec_helper 只是 rspec-rails 为您生成的标准帮助程序,我已经将spork prefork 块内的所有内容如下:

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|  
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
    config.use_transactional_fixtures = true
    config.infer_base_class_for_anonymous_controllers = false
  end
end

我做错了吗?还是 spork 坏了?

This is a copy+paste of an issue I created on github, but I'm asking here too in case someone knows how to fix it


Using spork 0.9.0.rc9, I've noticed that the timer which displays how long specs are taking to run is not resetting itself between runs and is instead outputting the total time that has accumulated since the spork server was started.

Steps to reproduce:

  1. start spork from console with command spork
  2. in another window run rspec . --drb
  3. observe that specs take X seconds to run and that console output verifies this
  4. wait 60 seconds, modify a controller spec, and repeat step 2
  5. observe that specs take about Y seconds to run, but console output claims that they took (X + Y + 60) seconds.
  6. wait 10 minutes, repeat step 2
  7. observe that specs run in Z seconds but console output puts the figure at (X + Y + Z + 600) seconds

My spec_helper is just the standard one that rspec-rails generates for you and I've put everything inside the spork prefork block as follows:

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|  
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
    config.use_transactional_fixtures = true
    config.infer_base_class_for_anonymous_controllers = false
  end
end

Am I doing it wrong? Or is spork borked?

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

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

发布评论

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

评论(1

是你 2024-12-17 11:09:58

有一个临时修复程序可以解决此问题,这是一个已知的 rspec 问题。

临时修复可能不适用于 rspec 的未来版本,如下所示:

Spork.each_run do
  # you are advised that this may break in future versions of rspec
  $rspec_start_time = Time.now  
end

更新:
Guard-rspec 此处 和 rspec-core 此处

There is a temporary fix for this, it is a known rspec issue.

The temporary fix, which may not work with future versions of rspec, is as follows:

Spork.each_run do
  # you are advised that this may break in future versions of rspec
  $rspec_start_time = Time.now  
end

UPDATE:
it was reported in guard-rspec here and in rspec-core here.

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