过度冗余的rspec故障输出

时间:2013-08-01 16:32:33

标签: ruby-on-rails rspec

当我快速失败运行rspec时,它给我的输出超出了我的需要。如下所示,运行时会打印一个错误,然后在摘要中再次打印。这在我进行视图测试时尤其麻烦,因为在我的控制台中可以渲染数百行标记。根本不好玩。

Running tests with args ["--color", "--failure-exit-code", "2", "--format", "RSpec::Instafail", "--format", "Guard::RSpec::Formatter", "--require", "rspec/instafail", "--require", "/Users/peter/.rvm/gems/ruby-1.9.3-p429/gems/guard-rspec-3.0.0/lib/guard/rspec/formatter.rb", "spec/views/layouts/application.html.erb_spec.rb"]...
  1) layouts/application.html.erb will fail
     Failure/Error: raise  "An example error"
     RuntimeError:
       An example error
     # ./spec/views/layouts/application.html.erb_spec.rb:9:in `block (2 levels) in <top (required)>'


Failures:

  1) layouts/application.html.erb will fail
     Failure/Error: raise  "An example error"
     RuntimeError:
       An example error
     # ./spec/views/layouts/application.html.erb_spec.rb:9:in `block (2 levels) in <top (required)>'

Finished in 0.07728 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/views/layouts/application.html.erb_spec.rb:8 # layouts/application.html.erb will fail
]2;[RSpec results] 1 examples, 1 failures

Randomized with seed 6737

前6行非常重要,接下来的16行会变成噪音。我怎么能省略它们?谢谢!

1 个答案:

答案 0 :(得分:1)

我认为你必须编写自己的自定义格式化程序。 documentation中的示例可能是您想要的 less 信息,但它应该为您提供一个开始。