From d066b9e01ccb2260fac8b2580c10e73335c7c7db Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 5 Feb 2026 20:38:00 +0100 Subject: Refactor type error to be more consistent [Bug #21864] Co-Authored-By: Benoit Daloze --- spec/ruby/core/module/define_method_spec.rb | 2 +- spec/ruby/core/module/instance_method_spec.rb | 2 +- spec/ruby/core/module/shared/class_eval.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/ruby/core/module') diff --git a/spec/ruby/core/module/define_method_spec.rb b/spec/ruby/core/module/define_method_spec.rb index c5dfc53764..a4fe4fad18 100644 --- a/spec/ruby/core/module/define_method_spec.rb +++ b/spec/ruby/core/module/define_method_spec.rb @@ -254,7 +254,7 @@ describe "Module#define_method" do -> { Class.new { define_method(obj, -> {}) } - }.should raise_error(TypeError, /can't convert Object to String/) + }.should raise_consistent_error(TypeError, /can't convert Object into String/) end it "raises a TypeError when the given method is no Method/Proc" do diff --git a/spec/ruby/core/module/instance_method_spec.rb b/spec/ruby/core/module/instance_method_spec.rb index 182cdf5c54..c6bc201520 100644 --- a/spec/ruby/core/module/instance_method_spec.rb +++ b/spec/ruby/core/module/instance_method_spec.rb @@ -79,7 +79,7 @@ describe "Module#instance_method" do obj = Object.new def obj.to_str() [] end - -> { ModuleSpecs::InstanceMeth.instance_method(obj) }.should raise_error(TypeError, /can't convert Object to String/) + -> { ModuleSpecs::InstanceMeth.instance_method(obj) }.should raise_consistent_error(TypeError, /can't convert Object into String/) end it "raises a NameError if the method has been undefined" do diff --git a/spec/ruby/core/module/shared/class_eval.rb b/spec/ruby/core/module/shared/class_eval.rb index 526d0a2036..b6e653a2ac 100644 --- a/spec/ruby/core/module/shared/class_eval.rb +++ b/spec/ruby/core/module/shared/class_eval.rb @@ -66,7 +66,7 @@ describe :module_class_eval, shared: true do it "raises a TypeError when the given filename can't be converted to string using to_str" do (file = mock('123')).should_receive(:to_str).and_return(123) - -> { ModuleSpecs.send(@method, "1+1", file) }.should raise_error(TypeError, /can't convert MockObject to String/) + -> { ModuleSpecs.send(@method, "1+1", file) }.should raise_consistent_error(TypeError, /can't convert MockObject into String/) end it "converts non string eval-string to string using to_str" do @@ -85,7 +85,7 @@ describe :module_class_eval, shared: true do -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError, "no implicit conversion of MockObject into String") (o = mock('123')).should_receive(:to_str).and_return(123) - -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError, /can't convert MockObject to String/) + -> { ModuleSpecs.send(@method, o) }.should raise_consistent_error(TypeError, /can't convert MockObject into String/) end it "raises an ArgumentError when no arguments and no block are given" do -- cgit v1.2.3