Skip to content

Commit 647cc21

Browse files
committed
✅ Avoid warning on redefining FakeServer handlers
1 parent d10881e commit 647cc21

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/net/imap/fake_server/command_router.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ module Routable
1010
def on(*command_names, &handler)
1111
scope = self.is_a?(Module) ? self : singleton_class
1212
command_names.each do |command_name|
13-
scope.define_method("handle_#{command_name.downcase}", &handler)
13+
method_name = :"handle_#{command_name.downcase}"
14+
scope.undef_method(method_name) if scope.method_defined?(method_name)
15+
scope.define_method(method_name, &handler)
1416
end
1517
end
1618
end

0 commit comments

Comments
 (0)