From 14192921f5eda76efa85a97ed3f1bfbf48e9a534 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 26 Feb 2025 11:13:41 +0900 Subject: [PATCH] Check LoadError first The message from dlerror is not our concern. --- spec/ruby/core/kernel/shared/require.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb index 080409117f..b31c89e3bf 100644 --- a/spec/ruby/core/kernel/shared/require.rb +++ b/spec/ruby/core/kernel/shared/require.rb @@ -223,7 +223,7 @@ describe :kernel_require, shared: true do it "loads c-extension file when passed absolute path without extension when no .rb is present" do # the error message is specific to what dlerror() returns path = File.join CODE_LOADING_DIR, "a", "load_fixture" - -> { @object.send(@method, path) }.should raise_error(Exception, /file too short|not a mach-o file|slice is not valid mach-o file/) + -> { @object.send(@method, path) }.should raise_error(LoadError) end end @@ -231,7 +231,7 @@ describe :kernel_require, shared: true do it "loads .bundle file when passed absolute path with .so" do # the error message is specific to what dlerror() returns path = File.join CODE_LOADING_DIR, "a", "load_fixture.so" - -> { @object.send(@method, path) }.should raise_error(Exception, /load_fixture\.bundle.+(file too short|not a mach-o file|slice is not valid mach-o file)/) + -> { @object.send(@method, path) }.should raise_error(LoadError) end end