首页 > 解决方案 > 如何抑制 RSpec 的失败输出?

问题描述

输出有 3 个部分:

Failures:

  1) Spec name
     Failure/Error: return ActiveRecord::Base.connection.exec_query(query_string) if Rails.env.test?

     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function group_concat(character varying, unknown) does not exist
       LINE 1: SELECT ...
                                   ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     # ./app/models/...
     # ./app/models/...
     # ./app/models/...
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function group_concat(character varying, unknown) does not exist
     #   LINE 1: SELECT ... as...
     #                               ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./app/models/....rb:7:in `query'

Finished in 15.8 seconds (files took 12.76 seconds to load)
69 examples, 11 failures

Failed examples:

rspec ./spec/models/foo_spec.rb:385 # ...
rspec ./spec/models/foo_spec.rb:385 # ...
rspec ./spec/models/foo_spec.rb:385 # ...

失败的次数很多,我对失败的总数更感兴趣。

如何将输出限制为:

Finished in 15.8 seconds (files took 12.76 seconds to load)
69 examples, 11 failures

标签: ruby-on-railsrspec

解决方案


不是我正在寻找的答案,但这很好用:

rspec | grep examples

推荐阅读