Skip to content

Commit 1213adf

Browse files
etiennebarriehsbt
authored andcommitted
[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 ruby/json@0dc1cd407e77 and ruby/json@caa5d8cdd748 in ruby. We can skip defining the test class entirely instead when ostruct is not available. ruby/json@6f6a4cdfd7
1 parent db027af commit 1213adf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

test/json/json_generic_object_test.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# frozen_string_literal: true
22
require_relative 'test_helper'
33

4-
class JSONGenericObjectTest < Test::Unit::TestCase
4+
# ostruct is required to test JSON::GenericObject
5+
begin
6+
require "ostruct"
7+
rescue LoadError
8+
return
9+
end
510

11+
class JSONGenericObjectTest < Test::Unit::TestCase
612
def setup
713
if defined?(JSON::GenericObject)
814
@go = JSON::GenericObject[ :a => 1, :b => 2 ]

0 commit comments

Comments
 (0)