# How to monkeypatch in a plugin

**URL:** <https://www.ruby-forum.com/t/how-to-monkeypatch-in-a-plugin/137755>\
**Category:** Rails\
**Created:** [May 16, 2008, 12:19am UTC](https://www.ruby-forum.com/t/how-to-monkeypatch-in-a-plugin/137755 "2008-05-16T00:19:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [May 16, 2008, 12:19am UTC](https://www.ruby-forum.com/t/how-to-monkeypatch-in-a-plugin/137755/1 "2008-05-16T00:19:56Z")

</div>

Hi all,

I’m working on a plugin that enables automatic profiling and  
benchmarking for unit tests. I need to monkeypatch  
Test::Unit::TestSuite to redefine the run method. Based on the example  
I see at [http://svn.jthopple.com/plugins/count\_limit\_associations](http://svn.jthopple.com/plugins/count_limit_associations), I  
thought I should be able to simply open the class in question in  
/lib/profile\_tests.rb, e.g.

module Test  
module Unit  
class Suite  
def run  
puts “My Run Method Used”  
…

In init.rb, I simply have

require ‘profile\_tests’

However, running my tests does not seem to use my definition of ‘run’.  
Am I missing something?

Thanks!

Brian

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [May 16, 2008, 12:41am UTC](https://www.ruby-forum.com/t/how-to-monkeypatch-in-a-plugin/137755/2 "2008-05-16T00:41:06Z")

</div>

Brian H. wrote:

> […]  
> However, running my tests does not seem to use my definition of ‘run’.  
> Am I missing something?
> 
> Thanks!
> 
> Brian

Ah, heck. ‘Suite’ should be ‘TestSuite’. Sorry for the noise. 🙂
