Skip to content

Commit 6f6a4cd

Browse files
committed
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 0dc1cd407e7775610f2bcaef6c1282369867f91c and caa5d8cdd7483647013af5e3d1701b0ed3ec8785 in ruby. We can skip defining the test class entirely instead when ostruct is not available.
1 parent 1d0aee8 commit 6f6a4cd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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)