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

Soften this test since YAML.dump may produce keys in other orders. #26860

Merged
merged 1 commit into from Oct 21, 2016

Conversation

@headius
Copy link
Contributor

@headius headius commented Oct 21, 2016

Summary

JRuby's YAML engine is not libyaml, and may produce keys in a different order. That led to this failure (the SOLE failure) in actionpack:

  1) Failure:
ParametersSerializationTest#test_yaml_serialization [/Users/headius/projects/rails/actionpack/test/controller/parameters/serialization_test.rb:17]:
--- expected
+++ actual
@@ -1,5 +1,5 @@
 "--- !ruby/object:ActionController::Parameters
+permitted: false
 parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
   key: :value
-permitted: false
 "

This patch modifies the test to use regexp matching for key lines rather than a string comparison.

@rails-bot
Copy link

@rails-bot rails-bot commented Oct 21, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @kaspth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

Copy link
Member

@kaspth kaspth left a comment

Nice!

actionpack/test/controller/parameters/serialization_test.rb Outdated
yaml_dump = YAML.dump(params)
assert_match /--- !ruby\/object:ActionController::Parameters/, yaml_dump
assert_match /parameters: !ruby\/hash:ActiveSupport::HashWithIndifferentAccess\n +key: :value/, yaml_dump
assert_match /permitted: false/, yaml_dump

This comment has been minimized.

@kaspth

kaspth Oct 21, 2016
Member

Let's wrap these in parens so they don't generate warnings on MRI 😁

This comment has been minimized.

@headius

headius Oct 21, 2016
Author Contributor

Can do!

@headius headius force-pushed the headius:soft_ordering_in_yaml_dump branch to fe09e7b Oct 21, 2016
@headius
Copy link
Contributor Author

@headius headius commented Oct 21, 2016

Repushed a cleaner version.

@tenderlove
Copy link
Member

@tenderlove tenderlove commented Oct 21, 2016

Just wanted to comment that this difference is not due to the YAML back ends. The reason it's different is that this example is serializing a Ruby object to YAML, and the order in which JRuby returns instance variables is allowed to differ from the order which MRI returns instance variables. Since Psych is just asking for a list of instance variables, the output may be different depending on your Ruby implementation.

@kaspth kaspth merged commit 5dce39e into rails:master Oct 21, 2016
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
codeclimate Code Climate didn't find any new or fixed issues.
Details
@kaspth
Copy link
Member

@kaspth kaspth commented Oct 21, 2016

Thanks, @headius!

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Oct 21, 2016

Backported in 5c9b16c

rafaelfranca added a commit that referenced this pull request Oct 21, 2016
Soften this test since YAML.dump may produce keys in other orders.
@headius headius deleted the headius:soft_ordering_in_yaml_dump branch Oct 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.