How to prevent RSpec from abbreviating match_array output?

微笑、不失礼 提交于 2021-01-29 04:38:50

问题


I have just noticed that RSpec's match_array is abbreviating the error response. e.g.,

expected collection contained: [beginning, of, the, array....end, of, the, array]

This did not use to be the case. Previously the output displayed the entire array contents, making it easier to identify what is causing the problem.

It has been some time since I've had a failing match_array in these tests, so I'm not sure what has changed. Is there a setting to provide a more verbose match_array message?


回答1:


You can configure RSpec to output full array values using the expect_with configuration max_formatted_output_length:

RSpec.configure do |rspec|
  rspec.expect_with :rspec do |c|
    c.max_formatted_output_length = nil
  end
end

Setting it to nil will prevent RSpec from truncating the formatted output! Setting it to an integer will change the maximum number of characters in the formatted output. It is 200 by default.

Documentation: https://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FExpectations%2FConfiguration:max_formatted_output_length=



来源:https://stackoverflow.com/questions/38670959/how-to-prevent-rspec-from-abbreviating-match-array-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!