让RSpec报告中间故障

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

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

运行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”文件以指定默认选项。

使用其他格式 ,例如--format documentation

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

 $ rspec spec/ --format documentation 

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

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