Skip to content
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

Change test expectation to handle Ruby's unstable sorting #1210

Merged
merged 1 commit into from
Oct 11, 2017

Conversation

mxygem
Copy link
Member

@mxygem mxygem commented Oct 11, 2017

Summary

Paraphrasing @enkessler who helped me pin down what was going on here (thanks!): Ruby doesn't guarantee the sort order of sort or sort_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 use match_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

  • Refactor (code change that does not change external functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@ghost ghost assigned mxygem Oct 11, 2017
@mxygem mxygem changed the title Fix sort issue on Win7 env Change test expectation to handle Ruby's unstable sorting Oct 11, 2017
@mxygem mxygem requested a review from enkessler October 11, 2017 03:35
@mxygem mxygem merged commit a1a4c5f into master Oct 11, 2017
@mxygem mxygem deleted the config-spec-windows-fix branch October 11, 2017 19:52
@mxygem mxygem added the 🐛 bug Defect / Bug label Oct 19, 2017
@lock
Copy link

lock bot commented Oct 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants