-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New differ #365
Comments
@benoittgt Thank you for looking into this. Has the diff issue - that with confusing outputs when strings are actually different - been solved in Rspec? |
@BKSpurgeon At the moment no. This imply lot's of work and I am quite too busy at the moment to tackle that. I am sorry. |
I would like to work on:
Do you think @JonRowe this is the correct move? |
Yes I think the first step is to make the differ configurable, with a reference implementation that uses diff-lcs, then we can add others including our own, we did make a start at this, there is a differ injected into expectations I believe... |
Hello! I know my gem There was a question of what new differ code in RSpec would offer and what the expectations would be around that. I will say that I followed my own wants and wishes when it came to developing |
There are some new kids on the block, https://github.com/bpohoriletz/hash_deep_diff, and its (spiritual?) ancestors https://github.com/CodingZeal/hash_diff and https://github.com/liufengyun/hashdiff. |
Realistically I think we'd vendor any new tool at this point, our needs aren't super complicated but its better to not rely on 3rd parties for us |
I got a Hash diff problem that keys have different order, the result is difficult to read. this code works: `spec/supports/hashdiff.rb module HashDiffPatcher
def diff_as_object(actual, expected)
if actual.instance_of?(Hash) && expected.instance_of?(Hash)
super(actual.sort.to_h, expected.sort.to_h)
else
super
end
end
end
RSpec::Support::Differ.prepend HashDiffPatcher |
Would you like to send a PR with some benchmarks, @xiaohui-zhangxh ? Questions to consider:
|
You are right, there is problem with uncomparable keys. because my test case is only for simple hash, so make a self-maintained patcher(support) is enough. To make a PR maybe Hashdiff solution is better. |
Any movement on this? Would be great! |
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.List of issues with current differ
have_attributes
matcher shows confusing results for BigDecimal values rspec-expectations#1064include
matcher is not diffable enough rspec-expectations#1321Gems that try to improve the differ
Attempt tried
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 newObjectFormater
but only to output diff of expected VS actual?At the moment it is difficult to change
ObjectFormater
.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"
The text was updated successfully, but these errors were encountered: