aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2013-08-18 02:36:41 -0500
committerGuillermo Iguaran <guilleiguaran@gmail.com>2013-08-18 09:04:09 -0500
commitc40111c346b91dcf05a2d1b2b7d46525f045989e (patch)
tree8fbd50a483ae025e5f6a11682c11f9eb96d8aed3 /activemodel/test
parentc4108b44af54a6a62d719389d636ed918dd4f595 (diff)
downloadrails-c40111c346b91dcf05a2d1b2b7d46525f045989e.tar.gz
rails-c40111c346b91dcf05a2d1b2b7d46525f045989e.tar.bz2
rails-c40111c346b91dcf05a2d1b2b7d46525f045989e.zip
Refactor serialization test for hash order
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/serializers/json_serialization_test.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb
index 8eb7a58e90..00a636e633 100644
--- a/activemodel/test/cases/serializers/json_serialization_test.rb
+++ b/activemodel/test/cases/serializers/json_serialization_test.rb
@@ -155,16 +155,15 @@ class JsonSerializationTest < ActiveModel::TestCase
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