gpt4 book ai didi

ruby-on-rails - save_and_open_page 和 spork,spork 正在丢失测试套件/输出

转载 作者:数据小太阳 更新时间:2023-10-29 06:39:44 25 4
gpt4 key购买 nike

当我用 spork 运行我的 rspec 测试时,每次我使用 capybara 的 save_and_open_page 时,spork 都会丢失测试套件......或者可能不再输出任何东西......

查看日志

# => without save_and_open_page
09:04:24 - INFO - Spork server for RSpec, Test::Unit successfully started

09:04:24 - INFO - Guard::RSpec is running
09:04:24 - INFO - Running all specs
Running tests with args ["--drb", "-f", "progress", "-r", "/Users/myuser/.rvm/gems/ruby-1.9.3-p392/gems/guard-rspec-2.5.2/lib/guard/rspec/formatter.rb", "-f", "Guard::RSpec::Formatter", "--failure-exit-code", "2", "spec"]...
................

Finished in 4.1 seconds
16 examples, 0 failures


Randomized with seed 50331

Done.

# => with save_and_open_page, no .... are shown anymore
09:04:29 - INFO - Guard is now watching at '/Users/myuser/coding/myproject'
09:04:39 - INFO - Running: spec/features/registration/registration_process_spec.rb
Running tests with args ["--drb", "-f", "progress", "-r", "/Users/myuser/.rvm/gems/ruby-1.9.3-p392/gems/guard-rspec-2.5.2/lib/guard/rspec/formatter.rb", "-f", "Guard::RSpec::Formatter", "--failure-exit-code", "2", "spec/features/registration/registration_process_spec.rb"]...
Done.

# => without save_and_open_page, also no .... anymore (after restart it works again)
[1] guard(main)> Running tests with args ["--drb", "-f", "progress", "-r", "/Users/myuser/.rvm/gems/ruby-1.9.3-p392/gems/guard-rspec-2.5.2/lib/guard/rspec/formatter.rb", "-f", "Guard::RSpec::Formatter", "--failure-exit-code", "2", "spec/features/registration/registration_process_spec.rb"]...
Done.

# => here i added some errors into my code... still no error message shown...
[1] guard(main)> Running tests with args ["--drb", "-f", "progress", "-r", "/Users/myuser/.rvm/gems/ruby-1.9.3-p392/gems/guard-rspec-2.5.2/lib/guard/rspec/formatter.rb", "-f", "Guard::RSpec::Formatter", "--failure-exit-code", "2", "spec/features/registration/registration_process_spec.rb"]...
Done.

# only works again after restarting spork

有什么建议吗?

最佳答案

不知何故,您的 STDOUT 正在被其他缓冲区替换。因此,Capybara 写入 STDOUT 的任何内容都将被忽略或在其他地方消耗。

尝试以下操作:

# Add global before/after blocks
before :each do
@old_stdout, @old_stderr = STDOUT, STDERR
end

after :each do
STDOUT, STDERR = @old_stdout, @old_stderr

# Some gems use $stdout and $stderr, instead of STDOUT and STDERR, replace those too
$stdout, $stderr = @old_stdout, @old_stderr
end

Capybara 的 save_and_open_page 使用 Launchy gem。所以我相信 STDOUTSTDERR 会被埋在其中一个 gem 中。

关于ruby-on-rails - save_and_open_page 和 spork,spork 正在丢失测试套件/输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15895522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com