Skip to content

Commit 7a8ec82

Browse files
committed
Use Time.new because JSON.unsafe_load losts fractions of a second and
JSON.unsafe_load with Time object returns String ``` 1) Failure: JSONCommonInterfaceTest#test_unsafe_load_default_options [/path/to/ruby/test/json/json_common_interface_test.rb:230]: <2025-09-03 14:28:31.293635 +0200> expected but was <"2025-09-03 14:28:31 +0200">. ```
1 parent 56c0b62 commit 7a8ec82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/json/json_common_interface_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def test_unsafe_load_default_options
226226
nan_json = '{ "foo": NaN }'
227227
assert JSON.unsafe_load(nan_json, nil)['foo'].nan?
228228
assert_equal nil, JSON.unsafe_load(nil, nil)
229-
t = Time.now
230-
assert_equal t, JSON.unsafe_load(JSON(t))
229+
t = Time.new(2025, 9, 3, 14, 50, 0)
230+
assert_equal t.to_s, JSON.unsafe_load(JSON(t)).to_s
231231
end
232232

233233
def test_unsafe_load_with_options

0 commit comments

Comments
 (0)