首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >save_and_open_page和spork,spork正在失去测试套件/输出

save_and_open_page和spork,spork正在失去测试套件/输出
EN

Stack Overflow用户
提问于 2013-04-09 15:10:10
回答 2查看 325关注 0票数 13

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

查看日志

代码语言:javascript
复制
# => 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

有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-09-21 07:25:35

我在http://blog.mikecordell.com/2013/08/14/guard-and-capybara's-save_and_open_page.html找到了所描述问题的真正解决方案。特别感谢本解决方案的实际作者。

只需添加:

代码语言:javascript
复制
RSpec.configure do |config|
  config.before(:each) do
    @old_stdout, @old_stderr = STDOUT, STDERR
  end

  config.after(:each) do
    $stdout, $stderr = @old_stdout, @old_stderr
  end
end

spec_helper.rb

票数 0
EN

Stack Overflow用户

发布于 2013-05-27 16:06:34

不知怎么的,你的STDOUT被其他的缓冲区替换了。因此,无论Capybara写给STDOUT的是什么,都会被忽略或在其他地方使用。

尝试以下操作:

代码语言:javascript
复制
# 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

水豚的save_and_open_page使用Launchy gem。因此,我认为STDOUTSTDERR在这些宝石中被卡住了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15895522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档