Unit testing or mocking Net::SMTP

Say I have a class that sends mail. It has a method with this in it:

Net::SMTP.start(host) { |smtp|
    smtp.send_mail(message, sender, *recipients)
}

How can I best unit test this?

Should I alias Net::SMTP.start to something else and replace it with a
mock implementation in my test case’s startup, then restore it in
teardown?

Any libraries or examples of where this is done elegantly?

···


matt