diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/json/decoding_test.rb | 17 | ||||
-rw-r--r-- | activesupport/test/json/encoding_test.rb | 3 |
2 files changed, 11 insertions, 9 deletions
diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index f0b0da32c8..93560fb5a2 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -2,10 +2,10 @@ require File.dirname(__FILE__) + '/../abstract_unit' class TestJSONDecoding < Test::Unit::TestCase TESTS = { - %({"returnTo":{"/categories":"/"}}) => {"returnTo" => {"/categories" => "/"}}, - %({returnTo:{"/categories":"/"}}) => {"returnTo" => {"/categories" => "/"}}, - %({"return\\"To\\":":{"/categories":"/"}}) => {"return\"To\":" => {"/categories" => "/"}}, - %({"returnTo":{"/categories":1}}) => {"returnTo" => {"/categories" => 1}}, + %q({"returnTo":{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}}, + %q({returnTo:{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}}, + %q({"return\\"To\\":":{"\/categories":"\/"}}) => {"return\"To\":" => {"/categories" => "/"}}, + %q({"returnTo":{"\/categories":1}}) => {"returnTo" => {"/categories" => 1}}, %({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]}, %({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]}, %({a: "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"}, @@ -23,11 +23,12 @@ class TestJSONDecoding < Test::Unit::TestCase %("\\"") => "\"", %(null) => nil, %(true) => true, - %(false) => false + %(false) => false, + %q("http:\/\/test.host\/posts\/1") => "http://test.host/posts/1" } - def test_json_decoding - TESTS.each do |json, expected| + TESTS.each do |json, expected| + define_method :"test_json_decoding_#{json}" do assert_nothing_raised do assert_equal expected, ActiveSupport::JSON.decode(json) end @@ -37,4 +38,4 @@ class TestJSONDecoding < Test::Unit::TestCase def test_failed_json_decoding assert_raises(ActiveSupport::JSON::ParseError) { ActiveSupport::JSON.decode(%({: 1})) } end -end
\ No newline at end of file +end diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb index 923f4b8396..8200dfcb62 100644 --- a/activesupport/test/json/encoding_test.rb +++ b/activesupport/test/json/encoding_test.rb @@ -14,7 +14,8 @@ class TestJSONEncoding < Test::Unit::TestCase [ 2.5, %(2.5) ]] StringTests = [[ 'this is the <string>', %("this is the \\074string\\076")], - [ 'a "string" with quotes', %("a \\"string\\" with quotes") ]] + [ 'a "string" with quotes', %("a \\"string\\" with quotes") ], + [ 'http://test.host/posts/1', %("http:\\/\\/test.host\\/posts\\/1")]] ArrayTests = [[ ['a', 'b', 'c'], %([\"a\", \"b\", \"c\"]) ], [ [1, 'a', :b, nil, false], %([1, \"a\", \"b\", null, false]) ]] |