diff options
author | Jean Boussier <[email protected]> | 2024-10-28 08:34:43 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-10-29 13:25:01 +0900 |
commit | b094ee3f23097f3e02c54476a0499e590e1bf5d7 (patch) | |
tree | 18a99a4dbce57198f43f839f07a3635180e1c79c /test | |
parent | 3c9be02af1e44a79191309cf727ede20cc576cb0 (diff) |
Handle all formatting configs potentially being `nil`.
Fix: https://github.com/ruby/json/issues/653
I don't think this was really fully supported in the past, but
it kinda worked with some of the implementations.
Diffstat (limited to 'test')
-rwxr-xr-x | test/json/json_generator_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index 1670445a7f..57c4e6ceeb 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -174,6 +174,27 @@ class JSONGeneratorTest < Test::Unit::TestCase assert s[:check_circular?] end + def test_falsy_state + object = { foo: [1, 2], bar: { egg: :spam }} + expected_json = JSON.generate( + object, + array_nl: "", + indent: "", + object_nl: "", + space: "", + space_before: "", + ) + + assert_equal expected_json, JSON.generate( + object, + array_nl: nil, + indent: nil, + object_nl: nil, + space: nil, + space_before: nil, + ) + end + def test_pretty_state state = JSON.create_pretty_state assert_equal({ |