问题
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