diff options
Diffstat (limited to 'activesupport/test/json')
-rw-r--r-- | activesupport/test/json/decoding_test.rb | 11 | ||||
-rw-r--r-- | activesupport/test/json/encoding_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/json/encoding_test_cases.rb | 8 |
3 files changed, 18 insertions, 3 deletions
diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 6d1d8f1b95..8d9587f248 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "abstract_unit" require "active_support/json" require "active_support/time" @@ -75,12 +77,17 @@ class TestJSONDecoding < ActiveSupport::TestCase } TESTS.each_with_index do |(json, expected), index| + fail_message = "JSON decoding failed for #{json}" + test "json decodes #{index}" do with_tz_default "Eastern Time (US & Canada)" do with_parse_json_times(true) do silence_warnings do - assert_equal expected, ActiveSupport::JSON.decode(json), "JSON decoding \ - failed for #{json}" + if expected.nil? + assert_nil ActiveSupport::JSON.decode(json), fail_message + else + assert_equal expected, ActiveSupport::JSON.decode(json), fail_message + end end end end diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb index 6d8f7cfbd0..80d03ec9d6 100644 --- a/activesupport/test/json/encoding_test.rb +++ b/activesupport/test/json/encoding_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "securerandom" require "abstract_unit" require "active_support/core_ext/string/inflections" diff --git a/activesupport/test/json/encoding_test_cases.rb b/activesupport/test/json/encoding_test_cases.rb index 8eac246937..5a4700459f 100644 --- a/activesupport/test/json/encoding_test_cases.rb +++ b/activesupport/test/json/encoding_test_cases.rb @@ -1,4 +1,10 @@ +# frozen_string_literal: true + require "bigdecimal" +require "date" +require "time" +require "pathname" +require "uri" module JSONTest class Foo @@ -23,7 +29,7 @@ module JSONTest end end - class MyStruct < Struct.new(:name, :value) + MyStruct = Struct.new(:name, :value) do def initialize(*) @unused = "unused instance variable" super |