Change number of characters displayed for mismatched comparisons

11 views
Skip to first unread message

Jack Royal-Gordon

unread,
Oct 10, 2020, 7:39:03 PM10/10/20
to rs...@googlegroups.com
I am comparing some complex array/hash structures for “eq”, and I would like to display the **entire** object if the comparison fails, without replacing the middle with ellipses to shorten the output. I know some work was done in this area in Issue #2535 in rspec-core, but looking at configuration the only setting I see that looks like it **might** have an effect is #max_displayed_failure_line_count, and setting that to 100 had no effect on the output.

If there is solution within the realm of custom matchers, I could do that since I am using a custom matcher I wrote in order to “customize" the rules of “eq” on these structures.

If the solution is something that must be applied to specific example groups, that would also be more than acceptable.

Phil Pirozhkov

unread,
Oct 10, 2020, 7:48:09 PM10/10/20
to Jack Royal-Gordon
I think you're looking for this option:

```
RSpec.configure do |config|
  config.expect_with :rspec do |expectations|
    expectations.max_formatted_output_length = 1000
  end
end
```

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/E8BD2E74-83B5-4381-BA73-A949B876CFE4%40pobox.com.

Jack Royal-Gordon

unread,
Oct 10, 2020, 9:01:24 PM10/10/20
to rs...@googlegroups.com
Thanks, Phil. That’s exactly what I was looking for. I never knew that additional configuration objects existed!

Phil Pirozhkov

unread,
Oct 11, 2020, 3:38:29 AM10/11/20
to Jack Royal-Gordon
You are always welcome, Jack!
I've actually have discovered this option quite recently myself. RSpec is an endless well of goodness.
Reply all
Reply to author
Forward
0 new messages