aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/json
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-10 13:36:42 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-10 13:36:42 -0300
commita59d661a82e684e23fd7295443e5d1264315df2e (patch)
treef2f855b35dc37527777b5b8572c1bdb05378b7f5 /activesupport/test/json
parenta71119335e312acde8d346ffc8fe109b1a99f4bd (diff)
downloadrails-a59d661a82e684e23fd7295443e5d1264315df2e.tar.gz
rails-a59d661a82e684e23fd7295443e5d1264315df2e.tar.bz2
rails-a59d661a82e684e23fd7295443e5d1264315df2e.zip
Fix test to ruby 2.0
The default enconding changed on Ruby 2.0
Diffstat (limited to 'activesupport/test/json')
-rw-r--r--activesupport/test/json/encoding_test.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index 67b648e6db..72366f9ab4 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -117,11 +117,18 @@ class TestJSONEncoding < Test::Unit::TestCase
assert_equal Encoding::UTF_8, result.encoding
end
- def test_utf8_hash_key
+ def test_utf8_hash_key_does_not_change_the_encoding
w = { '𠜎' => 'a' }
result = ActiveSupport::JSON.encode(w)
assert_equal '{"\\u070e":"a"}', result
- assert_equal Encoding::US_ASCII, result.encoding
+
+ if RUBY_VERSION >= '2.0'
+ expected_encoding = Encoding::UTF_8
+ else
+ expected_encoding = Encoding::US_ASCII
+ end
+
+ assert_equal expected_encoding, result.encoding
end
end