【问题标题】:how to get rid of the time-duration added to rspec when using --out?使用--out时如何摆脱添加到rspec的持续时间?
【发布时间】:2015-11-09 19:33:20
【问题描述】:

当我使用rspec --format documentation 输出到标准输出时,我得到如下信息:

User adds a third site and successfully credentials PayPal on FEB-17-2015
      Invoices the customer with a pro-rated Pro plan for the 3 unused days credited (PENDING: Not yet implemented)

这是期望的行为。

但是,当我使用 rspec --format documentation --out spec.txt 时,我得到了这个:

User adds a third site and successfully credentials PayPal on FEB-17-2015
[33m      Invoices the customer with a pro-rated Pro plan for the 3 unused days credited (PENDING: Not yet implemented)[0m

格式现在无法读取,此添加的一侧是[33m,另一侧是[0m

上述行为与文档中描述的示例背道而驰:

https://www.relishapp.com/rspec/rspec-core/v/2-4/docs/command-line/format-option#documentation-format-saved-to-a-file

问题:如何使文本匹配所需的标准输出?

【问题讨论】:

  • 不可读怎么定义?
  • 这些看起来像 ANSI 颜色代码,而不是持续时间 :) 尝试在 rspec 上禁用颜色输出(不知道该怎么做)。
  • 酷,我查了一下颜色,发现了这个:ruby-forum.com/topic/3447958

标签: ruby rspec


【解决方案1】:

[33m 不是持续时间;这是一个ANSI color code,这就是 RSpec 以彩色打印其输出的方式。 RSpec 旨在感知输出不会发送到 TTY 并在这种情况下禁用颜色,但它似乎不起作用。不过,您可以通过 --no-color 手动禁用它。

【讨论】:

  • 啊,好吧,我也从 .rspec 中删除了该选项——但我想我可以在命令行中添加 --no-color,这可能是一个更好的选择
猜你喜欢
  • 1970-01-01
  • 2015-12-25
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 1970-01-01
  • 2021-06-21
  • 1970-01-01
相关资源
最近更新 更多