summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Barrié <etienne.barrie@gmail.com>2025-09-15 16:26:43 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-16 17:17:32 +0900
commit1213adfe5526d65cce81a9fb127074130c8faea7 (patch)
treeb34a6832586f8f246e991fe57722783eacd6722c
parentdb027afebd3ee8ef3fd70ffea2ef7756f48003ce (diff)
[ruby/json] Better handle missing ostruct
In the Ruby test suite, this test class is causing trouble because ostruct is not available. Having an autoload for JSON::GenericObject but causing it not to define the constant causes a warning. See https://github.com/ruby/json/commit/0dc1cd407e77 and https://github.com/ruby/json/commit/caa5d8cdd748 in ruby. We can skip defining the test class entirely instead when ostruct is not available. https://github.com/ruby/json/commit/6f6a4cdfd7
-rw-r--r--test/json/json_generic_object_test.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/json/json_generic_object_test.rb b/test/json/json_generic_object_test.rb
index 995d57edaf..71d105976d 100644
--- a/test/json/json_generic_object_test.rb
+++ b/test/json/json_generic_object_test.rb
@@ -1,8 +1,14 @@
# frozen_string_literal: true
require_relative 'test_helper'
-class JSONGenericObjectTest < Test::Unit::TestCase
+# ostruct is required to test JSON::GenericObject
+begin
+ require "ostruct"
+rescue LoadError
+ return
+end
+class JSONGenericObjectTest < Test::Unit::TestCase
def setup
if defined?(JSON::GenericObject)
@go = JSON::GenericObject[ :a => 1, :b => 2 ]