加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – save_and_open_page和spork,spork正在失去测试

发布时间:2020-12-16 20:04:36 所属栏目:百科 来源:网络整理
导读:当我用spork运行我的rspec测试时,每次我使用capybara的save_and_open_page,spork正在丢失测试套件,或者可能不会输出任何东西… 看日志 # = without save_and_open_page09:04:24 - INFO - Spork server for RSpec,Test::Unit successfully started09:04:24 -
当我用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","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","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","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","spec/features/registration/registration_process_spec.rb"]...
Done.

# only works again after restarting spork

有什么建议么?

解决方法

不知何故,您的STDOUT正在被其他缓冲区所取代.所以无论是由水豚写的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.所以我相信STDOUT和STDERR在这些宝石之一被绊倒了.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读