Blob Blame History Raw
From c96d2d92017ad53045c9e9edc234fe82182b37ae Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Sun, 5 Nov 2023 22:37:23 +0900
Subject: [PATCH] fix: catch ruby3.3 format NoMethodError message

ruby3.3.0dev changes the error messages on NoMethodError with the following
commit / issue:

https://github.com/ruby/ruby/pull/6950
https://bugs.ruby-lang.org/issues/18285

So to catch this new NoMethodError message, modify regex accordingly.

Fixes #1578 .
---
 lib/shoulda/matchers/independent/delegate_method_matcher.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/shoulda/matchers/independent/delegate_method_matcher.rb b/lib/shoulda/matchers/independent/delegate_method_matcher.rb
index 5948188ec..d7b88dc86 100644
--- a/lib/shoulda/matchers/independent/delegate_method_matcher.rb
+++ b/lib/shoulda/matchers/independent/delegate_method_matcher.rb
@@ -400,7 +400,7 @@ def subject_handles_nil_delegate_object?
                 false
               rescue NoMethodError => e
                 if e.message =~
-                   /undefined method `#{delegate_method}' for nil:NilClass/
+                   /undefined method `#{delegate_method}' for nil/
                   false
                 else
                   raise e