Change test expectation to handle Ruby's unstable sorting #1210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Paraphrasing @enkessler who helped me pin down what was going on here (thanks!): Ruby doesn't guarantee the sort order of
sort
orsort_by
if the objects have the same comparison value.Details
Unfortunately, the test data we were using falls under the scenario above and it was causing a couple tests to fail on my machine.
[['progress', {}, 'file1'], ['profile', {}, 'file2']]
was going through a sort_by that should not have changed the output order of the arrays, but instead the following was being returned:[['profile', {}, 'file2'], ['progress', {}, 'file1']]
Instead of using rspec's
eq
check, I've changed the tests to usematch_array.
Motivation and Context
Fixing this primarily to allow me to dev on my Windows machine at home, but could also be extended to helping prevent this type of error from happening in the future.
How Has This Been Tested?
bundle exec rake
passes with no errors! 👍Screenshots (if appropriate):
Types of changes