diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-17 16:06:55 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-17 16:06:55 -0800 |
commit | d780d1f508c880c59d6d932bd052cb0b1c1c76b0 (patch) | |
tree | 11c9cf24210923020608443690d23cc94b683f71 /activesupport/test/json | |
parent | 6a8f7f0e04bce3ade8ff24fce80580cd23fae6d7 (diff) | |
download | rails-d780d1f508c880c59d6d932bd052cb0b1c1c76b0.tar.gz rails-d780d1f508c880c59d6d932bd052cb0b1c1c76b0.tar.bz2 rails-d780d1f508c880c59d6d932bd052cb0b1c1c76b0.zip |
ordering can change depending on ruby version, so parse the JSON and verify data structure equality
Diffstat (limited to 'activesupport/test/json')
-rw-r--r-- | activesupport/test/json/encoding_test.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb index f7ca39f0f6..d5fcbf15b7 100644 --- a/activesupport/test/json/encoding_test.rb +++ b/activesupport/test/json/encoding_test.rb @@ -234,9 +234,16 @@ class TestJSONEncoding < Test::Unit::TestCase json_custom = custom.to_json end - assert_equal %({"name":"David","email":"sample@example.com"}), json_strings - assert_equal %({"name":"David","date":"2010/01/01"}), json_string_and_date - assert_equal %({"sub":{"name":"David","date":"2010/01/01"},"name":"David"}), json_custom + assert_equal({"name" => "David", + "sub" => { + "name" => "David", + "date" => "2010/01/01" }}, JSON.parse(json_custom)) + + assert_equal({"name" => "David", "email" => "sample@example.com"}, + JSON.parse(json_strings)) + + assert_equal({"name" => "David", "date" => "2010/01/01"}, + JSON.parse(json_string_and_date)) end protected |