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 1 commit into from Oct 21, 2016


Copy link

@headius headius commented Oct 21, 2016


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.

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

@kaspth kaspth left a comment


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 Oct 21, 2016

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

This comment has been minimized.


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
Copy link
Contributor Author

@headius headius commented Oct 21, 2016

Repushed a cleaner version.

Copy link

@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
codeclimate Code Climate didn't find any new or fixed issues.
Copy link

@kaspth kaspth commented Oct 21, 2016

Thanks, @headius!

Copy link

@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
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.