Spork 计时器在运行之间不会重置
这是我在 github 上创建的 问题 的复制+粘贴,但我要问这里也以防万一有人知道如何修复它
使用 spork 0.9.0.rc9,我注意到显示规格运行所需时间的计时器不会在运行之间重置自身,而是输出已累积的总时间自从 spork 服务器启动以来。
重现步骤:
- 在另一个窗口中使用命令 spork
- 运行 rspec 从控制台启动 spork 。 --drb
- 观察到规范需要 X 秒才能运行,并且控制台输出验证此
- 等待 60 秒,修改控制器规范,然后重复步骤 2
- 观察到规范需要大约 Y 秒才能运行,但控制台输出声称它们花费了 (X + Y + 60) 秒。
- 等待 10 分钟,重复步骤 2
- 观察规范在 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:
- start spork from console with command spork
- in another window run rspec . --drb
- observe that specs take X seconds to run and that console output verifies this
- wait 60 seconds, modify a controller spec, and repeat step 2
- observe that specs take about Y seconds to run, but console output claims that they took (X + Y + 60) seconds.
- wait 10 minutes, repeat step 2
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个临时修复程序可以解决此问题,这是一个已知的 rspec 问题。
临时修复可能不适用于 rspec 的未来版本,如下所示:
更新:
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:
UPDATE:
it was reported in guard-rspec here and in rspec-core here.