Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor serialization test for hash order

  • Loading branch information...
commit c40111c346b91dcf05a2d1b2b7d46525f045989e 1 parent c4108b4
Guillermo Iguaran guilleiguaran authored
Showing with 6 additions and 7 deletions.
  1. +6 −7 activemodel/test/cases/serializers/json_serialization_test.rb
13 activemodel/test/cases/serializers/json_serialization_test.rb
View
@@ -155,16 +155,15 @@ def @contact.favorite_quote; "Constraints are liberating"; end
end
end
- test "as_json should keep the default order in the hash" do
+ test "as_json should keep the default order in the hash according to used engine" do
json = @contact.as_json
- attributes_order = %w(name age created_at awesome preferences)
- #Order on JRUBY is different
- if defined? JRUBY_VERSION
- attributes_order = %w(age name created_at awesome preferences)
+ # Check for original order only on MRI and sort for other implementations
+ if RUBY_ENGINE == 'ruby'
+ assert_equal %w(name age created_at awesome preferences), json.keys
+ else
+ assert_equal %w(age awesome created_at name preferences), json.keys.sort
end
-
- assert_equal attributes_order, json.keys
end
test "from_json should work without a root (class attribute)" do
Please sign in to comment.
Something went wrong with that request. Please try again.