How can I overriding class with proc and yield in test on rails?
问题 I have below classes(only for example), class Background def self.add_thread(&blcok) Thread.new do yield ActiveRecord::Base.connection.close end end end class Email def send_email_in_other_thread Background.add_thread do send_email end end def send_email UserMailer.greeting_email.deliver_now end end And below codes are for tests, class EmailTest < ActiveSupport::TestCase class Background def self.add_thread(&block) yield end end test 'should send email' do assert_difference 'ActionMailer: