Skip to content

Commit 430789d

Browse files
nobumatzbot
authored andcommitted
[ruby/psych] Ensure to remove the test constants
ruby/psych@dd3685aa67
1 parent d2a0e98 commit 430789d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/psych/test_yaml.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,6 @@ def test_ranges
10421042
end
10431043

10441044
def test_ruby_struct
1045-
Struct.send(:remove_const, :MyBookStruct) if Struct.const_defined?(:MyBookStruct)
10461045
# Ruby structures
10471046
book_struct = Struct::new( "MyBookStruct", :author, :title, :year, :isbn )
10481047
assert_to_yaml(
@@ -1074,11 +1073,12 @@ def test_ruby_struct
10741073
c: 123
10751074
EOY
10761075

1076+
ensure
1077+
Struct.__send__(:remove_const, :MyBookStruct) if book_struct
10771078
end
10781079

10791080
def test_ruby_data
10801081
omit "Data requires ruby >= 3.2" if RUBY_VERSION < "3.2"
1081-
Object.remove_const :MyBookData if Object.const_defined?(:MyBookData)
10821082
# Ruby Data value objects
10831083
book_class = Data.define(:author, :title, :year, :isbn)
10841084
Object.const_set(:MyBookData, book_class)
@@ -1112,6 +1112,8 @@ def test_ruby_data
11121112
c: 123
11131113
EOY
11141114

1115+
ensure
1116+
Object.__send__(:remove_const, :MyBookData) if book_class
11151117
end
11161118

11171119
def test_ruby_rational

0 commit comments

Comments
 (0)