-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Hello
Few people express the lack of clear informations with the RSpec diff output. As expressed [1][2]. @myronmarston explained the issue with diff-lcs and why we should use a new matcher for RSpec dedicated to RSpec semantics.
A differ written for RSpec, that understands the semantics of RSpec matching, would produce far better output. - source
List of issues with current differ
- on long strings, rspec may not display the part of the string that does not match #30 and on long strings, rspec may not display the part of the string that does not match #30
- Nested matchers are displayed in have_attributes error diff when any attribute fails validation rspec-expectations#1067
have_attributesmatcher shows confusing results for BigDecimal values rspec-expectations#1064- Add support for choosing differs #76
- Custom object display formatting rspec-expectations#496
- Suggestion: Alternate Hash differ output rspec-support#211
- Hash include with composable matcher gives misleading diff #86
includematcher is not diffable enough rspec-expectations#1321- related discussion allow inspectors to be registered for different objects rspec-support#516
Gems that try to improve the differ
- https://github.com/mcmire/super_diff
- https://github.com/playup/diff_matcher and https://github.com/playup/diff_matcher#use-with-rspec
Attempt tried
- on long strings, rspec may not display the part of the string that does not match #30
- level by level diff of unequal nested data structures. srsly. rspec-expectations#54 (comment)
- https://gist.github.com/alexch/474363
I planned long time ago to port the differ that is included with Elixir's ExUnit but didn't do it because of lack of time.
I am wondering what we are trying to do, what are the expectations. I have listed few issues with the current differ below. I think super-diff by @mcmire is a good start but the dependency should be dedicated to RSpec and deal with more types of objects.
I would love to work and get help on this subject for RSpec 4 but I need to know the expectations.
For example get rid of diff-lcs and create a new RSpec gem that will include diff mechanism plus a new ObjectFormater but only to output diff of expected VS actual?
At the moment it is difficult to change ObjectFormater.
The
ObjectFormatteris currently used in several ways, to format objects for descriptions etc, and to format them for expected / actual [source]
My last attempt to improve only string diff was a failure because ObjectFormater is used in various place and I had many failing tests in different RSpec gems.
Maybe we should first create a new class that will include diff mechanism (start with diff-lcs) plus a new ObjectFormater for actual/expected diff? For the end user it will mean no changes but for us it will be easier to start to work on a better diff output for RSpec 4?
"for each desired change, make the change easy (warning: this may be hard), then make the easy change"