让RSpec报告中间故障

时间:2011-08-30 23:36:54

标签: ruby testing rspec

有没有办法让RSpec报告失败,而不是长绿色/红色点列表? 我正在运行RSpec 2.5.0。

3 个答案:

答案 0 :(得分:3)

RSpec支持多种输出格式,使用--format选项指定。默认为“进度”,即您看到的点串。如果您更改为更详细的格式,您将在运行时看到红色/绿色的测试名称,但在最后打印的摘要之前,您仍然无法看到失败的原因。

运行rspec --help的其他格式选项是:

-f, --format FORMATTER           Choose a formatter
                                   [p]rogress (default - dots)
                                   [d]ocumentation (group and example names)
                                   [h]tml
                                   [t]extmate
                                   custom formatter class name

除了在命令行中指定格式外,还可以在主目录中放置“.rspec”文件以指定默认选项。

答案 1 :(得分:1)

使用different format,例如--format documentation

您可以将其作为参数传递给CLI。

$ rspec spec/ --format documentation

答案 2 :(得分:1)

你可以看一下那里的不同格式化程序。我想你正在寻找的那个FailingExamplesFormatter就像这样运行:

spec spec --require spec/runner/formatter/failing_examples_formatter.rb --formatter FailingExamplesFormatter