如何在Capybara集成测试中访问stdout或stderr [英] How to access stdout or stderr in a Capybara integration test

查看:65
本文介绍了如何在Capybara集成测试中访问stdout或stderr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试一些Capybara集成测试并遇到意外问题。当我在Capybara测试中设置断点时,可以检查变量,但不能调用 puts $ stdout.puts $ stderr.puts 。要理解我的意思,请看以下输出:

I'm trying to debug some Capybara integration tests and running into an unexpected issue. When I set a breakpoint inside a Capybara test, I can inspect variables, but i can not call puts or $stdout.puts or $stderr.puts. To understand what I mean look at this output:

(rdb:1) "foo"
"foo"
(rdb:1) puts "foo"
nil

大概是因为Capybara捕获stderr和stdout作为其标准操作的一部分,以使硒驱动程序等保持安静。我明白了,但是问题是,在ruby调试器中检查字符串会换行,这使得无法读取长格式像HTML这样的字符串。

Presumably this is because Capybara captures both stderr and stdout as part of its standard operation in order to keep things quiet with selenium drivers, etc. I get that, but the problem is that inspecting strings in the ruby debugger escapes newlines, which makes it impossible to read long formatted strings like HTML.

如何使用 IO#puts

推荐答案

您是否对Capybara-cli有所了解,也许会有助于以这种方式进行调试。

Have you taken a look at the Capybara-cli maybe that will help doing debuging that way.

https://github.com/vspy/capybara-console

这篇关于如何在Capybara集成测试中访问stdout或stderr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆